Fix ReferenceError in change node

and add a test case
This commit is contained in:
HirokiUchikawa
2018-07-19 14:44:21 +09:00
parent 75c29f1cb7
commit e675512fa3
2 changed files with 26 additions and 9 deletions

View File

@@ -143,7 +143,7 @@ module.exports = function(RED) {
if (rule.fromt === "msg") {
resolve(RED.util.getMessageProperty(msg,rule.from));
} else if (rule.fromt === 'flow' || rule.fromt === 'global') {
var contextKey = RED.util.parseContextStore(rule.from);
var contextKey = RED.util.parseContextStore(rule.from);
node.context()[rule.fromt].get(contextKey.key, contextKey.store, (err,fromValue) => {
if (err) {
reject(err);
@@ -166,12 +166,10 @@ module.exports = function(RED) {
try {
fromRE = new RegExp(fromRE, "g");
} catch (e) {
reject(new Error(RED._("change.errors.invalid-from",{error:e.message})));
return;
return Promise.reject(new Error(RED._("change.errors.invalid-from",{error:e.message})));
}
} else {
reject(new Error(RED._("change.errors.invalid-from",{error:"unsupported type: "+(typeof fromValue)})));
return;
return Promise.reject(new Error(RED._("change.errors.invalid-from",{error:"unsupported type: "+(typeof fromValue)})));
}
return {
fromType,