A tiny cross-platform promise based wrapper around child_process.spawn.
This project uses node and npm.
$ npm install shell-exec
$ # OR
$ yarn add shell-exec
const shellExec = require('shell-exec')
shellExec('echo Hi!').then(console.log).catch(console.log)
// Hi!
// { stdout: '', stderr: '', cmd: 'echo Hi!', code: 0 }
shellExec(command, options)
Parameters:
command
{String | Array} - String or Array of commands to runoptions
{Object} - Options object passed to child_process.spawn
The function then returns a Promise
.
MIT