@perl/qx
Version:
Run external commands and capture their status
27 lines (18 loc) • 645 B
Markdown
Run a command and capture its return status.
```js
const qx = require('@perl/qx')
// capture the output from `ls -l`
const output = await qx`ls -l`
// with promises
qx`ls -l`.then(output => console.log(output))
// also available in synchronous version
const output = qx.sync`ls -l`
// or as an ordinary function (handy because it avoids needing quoting)
const output = await qx('ls', '-l')
qx('ls', '-l').then(output => console.log(output))
const output = qx.sync('ls', '-l')
```
This is intended to provide the same functionality as the
[](https://perldoc.perl.org/perlop.html#Quote-Like-Operators) syntax.