JSPM

execa-output

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 22
  • Score
    100M100P100Q55519F
  • License MIT

A utility to display command output when using execa with listr.

Package Exports

  • execa-output

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (execa-output) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

execa-output

A utility to display command output when using execa with listr.

execa-output is responsible for creating the output sub text, like → text, as seen in the screenshot below.

Screenshot

Install

NPM

$ npm i execa-output

Yarn

$ yarn add execa-output

Usage

Basic usage is exactly the same as using execa.

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.

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.

const execao = require('execa-output');

execao('some', ['command'], null, (result) => {
    console.log('command output:', value);
});

Credit

I use np to release npm packages and I have always ❤️ it's simple, elegant presentation. It's how I learned about execa and listr, which I now use to build a lot of my own, custom npm scripts.

There's an issue on listr where people wanted to know how to display long running task output and it was recommended that one could reimplement / resue the code np uses.

This is exactly why execa-output was created.

All credit for this code goes to @sindresorhus and @SamVerschueren for the original implementation. 🙏

I simply modularized it for reuse.

License

MIT © Michael Novotny