shell-o
Synchronous shell command execution, benchmark tests prove shell-o is much faster than the shelljs exec method
shell-o is a wrapper for child_process.execSync
shell-o takes identical arguments ... (command[, options])
... but does not throw by default.
shell-o has been benchmarked at 10 times faster than shelljs!
On success it returns a JSON object:
var shello = require('shell-o')
var cmd = 'echo hello'
var cmdObj = shello(cmd, {stdio: 'pipe', encoding:'utf-8'})
expect(cmdObj).to.eql({
error: null,
stdout: 'hello\n',
stderr: '',
code: 0,
ok: true
})
On failure it returns a JSON object:
var shello = require('shell-o')
var cmd = 'blip blop'
var cmdObj = shello(cmd, {stdio: 'pipe', encoding:'utf-8'})
expect(cmdObj.error).to.be.an('error')
expect(cmdObj.error.message).to.match(/not found|not recognized/)
expect(cmdObj.stdout).to.equal('')
expect(cmdObj.stderr).to.match(/not found|not recognized/)
expect(cmdObj.code).to.be.above(0)
expect(cmdObj.ok).to.be.false
For the full list of available options see child_process.execSync
benchmarks
This output was generated by benchmark.js
********** shelljs **********
shelljs is slow
shelljs: 198.773ms
********** shell-o **********
shell-o is fast
shell-o: 17.926ms
Author says
But as the days of Noah were, so also will the coming of the Son of Man be. 38 For as in the days before the flood, they were eating and drinking, marrying and giving in marriage, until the day that Noah entered the ark, 39 and did not know until the flood came and took them all away, so also will the coming of the Son of Man be.
Matthew 24:37-39