Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manovotny/execa-output
A utility to display command output when using execa with listr.
https://github.com/manovotny/execa-output
child-process command execa listr observable output process task
Last synced: 12 days ago
JSON representation
A utility to display command output when using execa with listr.
- Host: GitHub
- URL: https://github.com/manovotny/execa-output
- Owner: manovotny
- License: mit
- Created: 2018-07-31T00:51:29.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-08T21:07:21.000Z (over 5 years ago)
- Last Synced: 2024-12-02T15:43:52.484Z (20 days ago)
- Topics: child-process, command, execa, listr, observable, output, process, task
- Language: JavaScript
- Homepage:
- Size: 666 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# execa-output
> A utility to display command output when using [execa](https://www.npmjs.com/package/execa) with [listr](https://www.npmjs.com/package/listr).
`execa-output` is responsible for creating the output sub text, like `→ text`, as seen in the screenshot below.
![Screenshot](assets/demo.gif)
## Install
### NPM
```
$ npm i execa-output
```### Yarn
```
$ yarn add execa-output
```## Usage
Basic usage is exactly the same as using `execa`.
```js
const execa = require('execa');
const execao = require('execa-output');
const Listr = require('listr');const tasks = new Listr([
{
task: () => execa('some', ['command']),
title: 'Comamnd without output or output you do not care to show'
},
{
task: () => execao('some', ['other', 'command']),
title: 'Command with output you want to show'
}
]);tasks.run().catch((error) => {
console.error(error);
});
```You can also pass in options to `execa`, just like when using `execa` directly.
```js
const execao = require('execa-output');const options = {};
execao('some', ['command'], options);
```Lastly, you can also provide a callback when you need access to the commnand output.
```js
const execao = require('execa-output');execao('some', ['command'], null, (result) => {
console.log('command output:', value);
});
```## Credit
I use [np](https://github.com/sindresorhus/np) to release npm packages and I have always :heart: it's simple, elegant presentation. It's how I learned about [execa](https://github.com/sindresorhus/execa) and [listr](https://github.com/SamVerschueren/listr), which I now use to build a lot of my own, custom [npm scripts](https://docs.npmjs.com/misc/scripts).
There's [an issue on listr](https://github.com/SamVerschueren/listr/issues/90) where people wanted to know how to display long running task output and [it was recommended](https://github.com/SamVerschueren/listr/issues/90#issuecomment-382702459) that one could reimplement / resue [the code np uses](https://github.com/sindresorhus/np/blob/5d923655a3986d04ea14035d20d5c0c16964b7fe/index.js#L17-L25).
This is exactly why `execa-output` was created.
All credit for this code goes to [@sindresorhus](https://github.com/sindresorhus) and [@SamVerschueren](https://github.com/SamVerschueren) for the original implementation. :pray:
I simply modularized it for reuse.
## License
MIT © [Michael Novotny](https://manovotny.com)