Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else if (defaultName) {
// No 'default' listed, so pick first in list as the default
stores["_"] = stores[defaultName];
defaultStore = defaultName;
defaultIsAlias = true;
} else {
// else there were no stores list the config object - fall through
// to below where we default to a memory store
storeList = ["memory"];
defaultStore = "memory";
}
hasConfiguredStore = true;
storeList = Object.keys(stores).filter(n=>!(defaultIsAlias && n==="default") && n!== "_");
} else {
// No configured plugins
log.info(log._("context.log-store-init", {name:"default", info:"module=memory"}));
promises.push(stores["_"].open())
storeList = ["memory"];
defaultStore = "memory";
}
return resolve(Promise.all(promises));
}).catch(function(err) {
throw new Error(log._("context.error-loading-module",{message:err.toString()}));
});
return;
} catch(backupStatErr) {
// Empty flow file, no back-up file
return resolve(emptyResponse);
}
}
try {
return resolve(parseJSON(data));
} catch(parseErr) {
log.warn(log._("storage.localfilesystem.invalid",{type:type}));
return resolve(emptyResponse);
}
} else {
if (type === 'flow') {
log.info(log._("storage.localfilesystem.create",{type:type}));
}
resolve(emptyResponse);
}
});
});
function getFlows() {
if (!initialFlowLoadComplete) {
initialFlowLoadComplete = true;
log.info(log._("storage.localfilesystem.user-dir",{path:settings.userDir}));
if (activeProject) {
// At this point activeProject will be a string, so go load it and
// swap in an instance of Project
return loadProject(activeProject).then(function() {
log.info(log._("storage.localfilesystem.projects.active-project",{project:activeProject.name||"none"}));
log.info(log._("storage.localfilesystem.flows-file",{path:flowsFullPath}));
return getFlows();
});
} else {
if (projectsEnabled) {
log.warn(log._("storage.localfilesystem.projects.no-active-project"))
} else {
projectLogMessages.forEach(log.warn);
}
log.info(log._("storage.localfilesystem.flows-file",{path:flowsFullPath}));
}
return loadProject(activeProject).then(function() {
log.info(log._("storage.localfilesystem.projects.active-project",{project:activeProject.name||"none"}));
log.info(log._("storage.localfilesystem.flows-file",{path:flowsFullPath}));
return getFlows();
});
} else {