@cush/exec
TypeScript icon, indicating that this package has built-in type declarations

1.8.0 • Public • Published

@cush/exec

Easy shell execution

const exec = require('@cush/exec');

// Sync version
try {
  const stdout = exec.sync('npm root -g');
  console.log(stdout);
} catch(stderr) {
  console.error(stderr);
}

// Async version
exec('git status --porcelain')
  .then(stdout => {
    console.log(stdout);
  }, stderr => {
    console.error(stderr);
  });

// Child process options
const files = await exec('ls -a', {
  cwd: 'path/to/dir'
});

// Additional arguments
const status = await exec('git status', [
  porcelain ? '--porcelain' : null, // null and undefined values are filtered out
]);

Available options are described here.

Notes

  • An error is thrown (or the promise is rejected) whenever the exit code of the child process is non-zero.

Readme

Keywords

none

Package Sidebar

Install

npm i @cush/exec

Weekly Downloads

47

Version

1.8.0

License

MIT

Unpacked Size

8.08 kB

Total Files

5

Last publish

Collaborators

  • aleclarson