shelljs.exec
Drop-in replacement for shelljs' slow exec method, 5x faster
shelljs.exec is a wrapper for child_process.execSync
IGNORE THIS README, IT IS BEING UPDATED RIGHT NOW
IGNORE THIS README, IT IS BEING UPDATED RIGHT NOW
IGNORE THIS README, IT IS BEING UPDATED RIGHT NOW
shelljs.exec takes identical arguments ... (command[, options])
... but does not throw by default.
shelljs.exec has been benchmarked at 10 times faster than shelljs!
On success it returns a JSON object:
var shello = require('shelljs.exec')
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('shelljs.exec')
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
********** shelljs.exec **********
shelljs.exec is fast
shelljs.exec: 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