1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge branch 'master' into repackage

This commit is contained in:
Nick O'Leary 2018-08-16 20:43:15 +01:00
commit 6b79c6135f
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
8 changed files with 61 additions and 15 deletions

View File

@ -881,7 +881,6 @@ RED.diff = (function() {
}
}
}
var properties = Object.keys(node).filter(function(p) { return p!='inputLabels'&&p!='outputLabels'&&p!='z'&&p!='wires'&&p!=='x'&&p!=='y'&&p!=='id'&&p!=='type'&&(!def.defaults||!def.defaults.hasOwnProperty(p))});
if (def.defaults) {
properties = properties.concat(Object.keys(def.defaults));
@ -889,6 +888,13 @@ RED.diff = (function() {
if (node.type !== 'tab') {
properties = properties.concat(['inputLabels','outputLabels']);
}
if ( ((localNode && localNode.hasOwnProperty('icon')) || (remoteNode && remoteNode.hasOwnProperty('icon'))) &&
properties.indexOf('icon') === -1
) {
properties.unshift('icon');
}
properties.forEach(function(d) {
localChanged = false;
remoteChanged = false;

View File

@ -1110,7 +1110,7 @@ RED.editor = (function() {
changed = true;
}
} else {
if (icon !== defaultIcon) {
if (icon !== "" && icon !== defaultIcon) {
changes.icon = editing_node.icon;
editing_node.icon = icon;
changed = true;

View File

@ -283,6 +283,9 @@ module.exports = function(RED) {
}
}
function applyRules(msg, currentRule) {
if (currentRule >= node.rules.length) {
return Promise.resolve(msg);
}
var r = node.rules[currentRule];
var rulePromise;
if (r.t === "move") {

View File

@ -166,12 +166,10 @@ function start() {
if (settings.httpStatic) {
log.info(log._("runtime.paths.httpStatic",{path:path.resolve(settings.httpStatic)}));
}
redNodes.loadContextsPlugin().then(function () {
return redNodes.loadContextsPlugin().then(function () {
redNodes.loadFlows().then(redNodes.startFlows).catch(function(err) {});
started = true;
});
}).catch(function(err) {
console.log(err);
});
});
}

View File

@ -163,7 +163,12 @@
"error-module-not-defined": "Context store '__storage__' missing 'module' option",
"error-invalid-module-name": "Invalid context store name: '__name__'",
"error-invalid-default-module": "Default context store unknown: '__storage__'",
"unknown-store": "Unknown context store '__name__' specified. Using default store."
"unknown-store": "Unknown context store '__name__' specified. Using default store.",
"error-loading-module": "Error loading context store: __message__",
"localfilesystem": {
"error-circular": "Context __scope__ contains a circular reference that cannot be persisted",
"error-write": "Error writing context: __message__"
}
}
}

View File

@ -170,6 +170,8 @@ function load() {
defaultStore = "memory";
}
return resolve(Promise.all(promises));
}).catch(function(err) {
throw new Error(log._("context.error-loading-module",{message:err.toString()}));
});
}

View File

@ -104,8 +104,6 @@ function loadFile(storagePath){
}else{
return Promise.resolve(undefined);
}
}).catch(function(err){
throw Promise.reject(err);
});
}
@ -113,9 +111,21 @@ function listFiles(storagePath) {
var promises = [];
return fs.readdir(storagePath).then(function(files) {
files.forEach(function(file) {
promises.push(fs.readdir(path.join(storagePath,file)).then(function(subdirFiles) {
return subdirFiles.map(subfile => path.join(file,subfile));
}))
if (!/^\./.test(file)) {
var fullPath = path.join(storagePath,file);
var stats = fs.statSync(fullPath);
if (stats.isDirectory()) {
promises.push(fs.readdir(fullPath).then(function(subdirFiles) {
var result = [];
subdirFiles.forEach(subfile => {
if (/\.json$/.test(subfile)) {
result.push(path.join(file,subfile))
}
});
return result;
}))
}
}
});
return Promise.all(promises);
}).then(dirs => dirs.reduce((acc, val) => acc.concat(val), []));
@ -172,7 +182,7 @@ LocalFileSystem.prototype.open = function(){
if(err.code == 'ENOENT') {
return fs.ensureDir(self.storageBaseDir);
}else{
return Promise.reject(err);
throw err;
}
}).then(function() {
self._flushPendingWrites = function() {
@ -185,7 +195,7 @@ LocalFileSystem.prototype.open = function(){
var context = newContext[scope];
var stringifiedContext = stringify(context);
if (stringifiedContext.circular && !self.knownCircularRefs[scope]) {
log.warn("Context "+scope+" contains a circular reference that cannot be persisted");
log.warn(log._("error-circular",{scope:scope}));
self.knownCircularRefs[scope] = true;
} else {
delete self.knownCircularRefs[scope];
@ -249,7 +259,11 @@ LocalFileSystem.prototype.set = function(scope, key, value, callback) {
// there's a pending write which will handle this
return;
} else {
this._pendingWriteTimeout = setTimeout(function() { self._flushPendingWrites.call(self)}, this.flushInterval);
this._pendingWriteTimeout = setTimeout(function() {
self._flushPendingWrites.call(self).catch(function(err) {
log.error(log._("context.localfilesystem.error-write",{message:err.toString()}))
});
}, this.flushInterval);
}
} else if (callback && typeof callback !== 'function') {
throw new Error("Callback must be a function");
@ -272,7 +286,7 @@ LocalFileSystem.prototype.set = function(scope, key, value, callback) {
}
var stringifiedContext = stringify(obj);
if (stringifiedContext.circular && !self.knownCircularRefs[scope]) {
log.warn("Context "+scope+" contains a circular reference that cannot be persisted");
log.warn(log._("error-circular",{scope:scope}));
self.knownCircularRefs[scope] = true;
} else {
delete self.knownCircularRefs[scope];

View File

@ -78,6 +78,24 @@ describe('change Node', function() {
done();
});
});
it('should no-op if there are no rules', function(done) {
var flow = [{"id":"changeNode1","type":"change","rules":[],"action":"","property":"","from":"","to":"","reg":false,"name":"changeNode","wires":[["helperNode1"]]},
{id:"helperNode1", type:"helper", wires:[]}];
helper.load(changeNode, flow, function() {
var changeNode1 = helper.getNode("changeNode1");
var helperNode1 = helper.getNode("helperNode1");
helperNode1.on("input", function(msg) {
try {
msg.should.eql(sentMsg);
done();
} catch(err) {
done(err);
}
});
var sentMsg = {payload:"leaveMeAlong"};
changeNode1.receive(sentMsg);
});
});
describe('#set' , function() {