Are you sure node.js execute system command synchronously?

Submitted by: Administrator
There's an excellent module for flow control in node.js called asyncblock. If wrapping the code in a function is OK for your case, the following sample may be considered:

var asyncblock = require('asyncblock');
var exec = require('child_process').exec;

asyncblock(function (flow) {
exec('node -v', flow.add());
result = flow.wait();
console.log(result); // There'll be trailing n in the output

// Some other jobs
console.log('More results like if it were sync...');
});
Submitted by: Administrator

Read Online Node.js Job Interview Questions And Answers