Unix
How to print pretty JSON in terminal
var jsonObj = { hi: 'hello' };
console.log(JSON.stringify(jsonObj, null, 2));
How to run bash commands from NodeJS
use
child_process.exec
to run bash commands
var exec = require('child_process').exec;
var child;
// executes `pwd`
child = exec("pwd", function (error, stdout, stderr) {
sys.print('stdout: ' + stdout);
sys.print('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});