From 4fb7f099dec85aec1b4ac76a29a7c7f207c9fe76 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Tue, 29 Mar 2016 15:39:54 +0200 Subject: [PATCH] Output node_helper output to console. --- js/electron.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/js/electron.js b/js/electron.js index 224c6554..cd2a4179 100755 --- a/js/electron.js +++ b/js/electron.js @@ -40,11 +40,29 @@ var module_loader = walk.walk(__dirname + '/../modules', { followLinks: false } module_loader.on('file', function(root, stat, next) { //if file is called node_helper.js load it if (stat.name == "node_helper.js"){ + var module = (root + '/' + stat.name).split("/"); + var moduleName = module[module.length-2]; + //start module as child - spawn('node', [root + '/' + stat.name]) + var child = spawn('node', [root + '/' + stat.name]) + + // Make sure the output is logged. + child.stdout.on('data', function(data) { + process.stdout.write(moduleName + ': ' + data); + }); + + child.stderr.on('data', function(data) { + process.stdout.write(moduleName + ': ' + data); + }); + + child.on('close', function(code) { + console.log(moduleName + ' closing code: ' + code); + }); + + //Log module name - var module = (root + '/' + stat.name).split("/") - console.log("Started helper script for module " + module[module.length-2] + "."); + + console.log("Started helper script for module " + moduleName + "."); } next(); });