Skip to content
Permalink
Browse files

Removes dependency on filesystem in node-red

  • Loading branch information...
Saevon committed Jul 16, 2015
1 parent 6b03379 commit 0da7a1bb740a5aeaabbdfabf01c616f857c3f714
Showing with 29 additions and 2 deletions.
  1. +1 −1 red/nodes/credentials.js
  2. +4 −0 red/nodes/flows.js
  3. +8 −1 red/nodes/registry/index.js
  4. +16 −0 red/storage/localfilesystem.js
@@ -18,7 +18,7 @@ var when = require("when");

var log = require("../log");

var needsPermission = require("../api/auth").needsPermission;
//var needsPermission = require("../api/auth").needsPermission;

var credentialCache = {};
var storage = null;
@@ -71,6 +71,10 @@ var flowNodes = module.exports = {
get: function(i) {
return activeFlow.getNode(i);
},

setActiveFlow: function(flow) {
activeFlow = flow;
},

eachNode: function(cb) {
activeFlow.eachNode(cb);
@@ -26,13 +26,20 @@ var settings;

function init(_settings) {
settings = _settings;
loader.init(settings);

if (!settings.noFileSystem) {
loader.init(settings);
}
registry.init(settings,loader);
}
//TODO: defaultNodesDir/disableNodePathScan are to make testing easier.
// When the tests are componentized to match the new registry structure,
// these flags belong on localfilesystem.load, not here.
function load(defaultNodesDir,disableNodePathScan) {
if (settings.noFileSystem) {
return when.resolve({});
}

return loader.load(defaultNodesDir,disableNodePathScan);
}

@@ -127,6 +127,10 @@ var localfilesystem = {

var promises = [];

if (settings.noFileSystem) {
return;
}

if (!settings.userDir) {
if (fs.existsSync(fspath.join(process.env.NODE_RED_HOME,".config.json"))) {
settings.userDir = process.env.NODE_RED_HOME;
@@ -184,6 +188,10 @@ var localfilesystem = {
},

getFlows: function() {
if (settings.noFileSystem) {
return when.resolve(settings.flowData);
}

return when.promise(function(resolve) {
log.info(log._("storage.localfilesystem.user-dir",{path:settings.userDir}));
log.info(log._("storage.localfilesystem.flows-file",{path:flowsFullPath}));
@@ -216,6 +224,10 @@ var localfilesystem = {
},

getCredentials: function() {
if (settings.noFileSystem) {
return when.resolve(settings.credentialData);
}

return when.promise(function(resolve) {
fs.exists(credentialsFile, function(exists) {
if (exists) {
@@ -251,6 +263,10 @@ var localfilesystem = {
},

getSettings: function() {
if (settings.noFileSystem) {
return when.resolve(settings.settingsData);
}

if (fs.existsSync(globalSettingsFile)) {
return nodeFn.call(fs.readFile,globalSettingsFile,'utf8').then(function(data) {
if (data) {

0 comments on commit 0da7a1b

Please sign in to comment.
You can’t perform that action at this time.