NodeJS - Spawn Child Process

import path from 'path'; var cp = require('child_process'); let args = []; let child = cp.spawn('bash', [path.join(process.env.SCRIPTS_ROOT || "", process.env.SCRIPT_APPLY_DAILY_UPDATES || "")].concat(args), { stdio: 'inherit' }); child.on('close', (code: any) => { console.log("Close Code: " + code); }); child.stdout.on('data', function (data: any) { stdout.push(data); }); child.stderr.on('data', function (data: any) { stderr.push(data); }); child.on('exit', function () { if (stderr.length) { // Handle errors } });

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.