Reputation: 866
I am creating a cakefile using node.js and want to know if a child_process has ended before moving on the next one.
{exec} = require 'child_process'
exec 'casperjs test.js', (err, stdout, stderr) ->
err && throw err
log stdout
if //exec has finished
log "finished executing"
Upvotes: 4
Views: 6858
Reputation: 1971
Alternativly you can use 'execSync", in order to go on step by step
var c = require('child_process');
var cliCommand = 'ls';
var result = c.execSync(cliCommand);
Upvotes: 0
Reputation: 348992
When the callback of exec
is called, the process has already been terminated. There's no need to add an additional check.
For spawn
, you can bind an exit
event listener.
Upvotes: 8