mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add 'node' object to Function close scope
This commit is contained in:
parent
11475b0c38
commit
d5f4f987f2
@ -347,7 +347,21 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
node.script = vm.createScript(functionText, createVMOpt(node, ""));
|
node.script = vm.createScript(functionText, createVMOpt(node, ""));
|
||||||
if (node.fin && (node.fin !== "")) {
|
if (node.fin && (node.fin !== "")) {
|
||||||
var finText = "(function () {\n"+node.fin +"\n})();";
|
var finText = `(function () {
|
||||||
|
var node = {
|
||||||
|
id:__node__.id,
|
||||||
|
name:__node__.name,
|
||||||
|
log:__node__.log,
|
||||||
|
error:__node__.error,
|
||||||
|
warn:__node__.warn,
|
||||||
|
debug:__node__.debug,
|
||||||
|
trace:__node__.trace,
|
||||||
|
status:__node__.status,
|
||||||
|
send: function(msgs, cloneMsg) {
|
||||||
|
__node__.error("Cannot send from close function");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
`+node.fin +`})();`;
|
||||||
finOpt = createVMOpt(node, " cleanup");
|
finOpt = createVMOpt(node, " cleanup");
|
||||||
finScript = new vm.Script(finText, finOpt);
|
finScript = new vm.Script(finText, finOpt);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user