Socket
Socket
Sign inDemoInstall

exec-sh

Package Overview
Dependencies
1
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.2 to 0.3.0

17

lib/exec-sh.js

@@ -85,2 +85,19 @@ var cp = require('child_process')

execSh.promise = function (command, options) {
return new Promise(function (resolve, reject) {
execSh(command, options, function (err, stdout, stderr) {
if (err) {
err.stdout = stdout
err.stderr = stderr
return reject(err)
}
resolve({
stderr: stderr,
stdout: stdout
})
})
})
}
module.exports = execSh

2

package.json
{
"name": "exec-sh",
"version": "0.2.2",
"version": "0.3.0",
"description": "Execute shell command forwarding all stdio.",

@@ -5,0 +5,0 @@ "main": "lib/exec-sh.js",

@@ -69,2 +69,25 @@ # exec-sh

## Promise Interface
```javascript
var execShPromise = require("exec-sh").promise;
// run interactive bash shell
const run = async () => {
let out;
try {
out = await execShPromise('pwd', true);
} catch (e) {
return console.log('Error: ', e);
return console.log('Stderr: ', e.stderr);
return console.log('Stdout: ', e.stdout);
}
console.log('out: ', out.stdout, out.stderr);
}
run();
```
## Public API

@@ -71,0 +94,0 @@

@@ -13,2 +13,6 @@ /* global describe, it, beforeEach, afterEach */

})
it('should export promise interface', function () {
assert.strictEqual(typeof execSh.promise, 'function')
})
})

@@ -149,3 +153,23 @@

})
it('promise interface: should return promise', function () {
assert(execSh.promise('command') instanceof Promise)
})
it('promise interface: should resolve with stderr and stdout', function (done) {
execSh.promise('command').then(function (data) {
assert(data.hasOwnProperty('stdout'))
assert(data.hasOwnProperty('stderr'))
done()
})
})
it('promise interface: should reject promise when exceptions thrown by spawn', function (done) {
spawn.throws()
execSh.promise('command').catch(function (err) {
assert(err instanceof Error)
done()
})
})
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc