mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge branch 'master' into dev
This commit is contained in:
@@ -19,6 +19,8 @@ module.exports = function(RED) {
|
||||
|
||||
var util = require("util");
|
||||
var vm = require("vm");
|
||||
var acorn = require("acorn");
|
||||
var acornWalk = require("acorn-walk");
|
||||
|
||||
function sendResults(node,send,_msgid,msgs,cloneFirstMessage) {
|
||||
if (msgs == null) {
|
||||
@@ -102,14 +104,7 @@ module.exports = function(RED) {
|
||||
throw new Error(RED._("function.error.externalModuleNotAllowed"));
|
||||
}
|
||||
|
||||
var handleNodeDoneCall = true;
|
||||
|
||||
// Check to see if the Function appears to call `node.done()`. If so,
|
||||
// we will assume it is well written and does actually call node.done().
|
||||
// Otherwise, we will call node.done() after the function returns regardless.
|
||||
if (/node\.done\s*\(\s*\)/.test(node.func)) {
|
||||
handleNodeDoneCall = false;
|
||||
}
|
||||
|
||||
var functionText = "var results = null;"+
|
||||
"results = (async function(msg,__send__,__done__){ "+
|
||||
@@ -130,6 +125,26 @@ module.exports = function(RED) {
|
||||
"};\n"+
|
||||
node.func+"\n"+
|
||||
"})(msg,__send__,__done__);";
|
||||
|
||||
var handleNodeDoneCall = true;
|
||||
|
||||
// Check to see if the Function appears to call `node.done()`. If so,
|
||||
// we will assume it is well written and does actually call node.done().
|
||||
// Otherwise, we will call node.done() after the function returns regardless.
|
||||
if (/node\.done\s*\(\s*\)/.test(functionText)) {
|
||||
// We have spotted the code contains `node.done`. It could be in a comment
|
||||
// so need to do the extra work to parse the AST and examine it properly.
|
||||
acornWalk.simple(acorn.parse(functionText,{ecmaVersion: "latest"} ), {
|
||||
CallExpression(astNode) {
|
||||
if (astNode.callee && astNode.callee.object) {
|
||||
if (astNode.callee.object.name === "node" && astNode.callee.property.name === "done") {
|
||||
handleNodeDoneCall = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
var finScript = null;
|
||||
var finOpt = null;
|
||||
node.topic = n.topic;
|
||||
|
@@ -217,6 +217,10 @@ module.exports = function(RED) {
|
||||
|
||||
function applyRules(node, msg, property,state,done) {
|
||||
if (!state) {
|
||||
if (node.rules.length === 0) {
|
||||
done(undefined, []);
|
||||
return;
|
||||
}
|
||||
state = {
|
||||
currentRule: 0,
|
||||
elseflag: true,
|
||||
|
@@ -15,6 +15,8 @@
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"acorn": "8.3.0",
|
||||
"acorn-walk": "8.1.0",
|
||||
"ajv": "8.2.0",
|
||||
"body-parser": "1.19.0",
|
||||
"cheerio": "0.22.0",
|
||||
@@ -37,7 +39,7 @@
|
||||
"on-headers": "1.0.2",
|
||||
"raw-body": "2.4.1",
|
||||
"request": "2.88.0",
|
||||
"ws": "6.2.1",
|
||||
"ws": "6.2.2",
|
||||
"xml2js": "0.4.23",
|
||||
"iconv-lite": "0.6.2"
|
||||
}
|
||||
|
Reference in New Issue
Block a user