mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Add 'node' object to Function close scope
This commit is contained in:
		| @@ -347,7 +347,21 @@ module.exports = function(RED) { | ||||
|             } | ||||
|             node.script = vm.createScript(functionText, createVMOpt(node, "")); | ||||
|             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"); | ||||
|                 finScript = new vm.Script(finText, finOpt); | ||||
|             } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user