0.1.0 • Published 4 years ago

actions-exec-listener v0.1.0

Weekly downloads
154
License
MIT
Repository
github
Last release
4 years ago

actions-exec-listener

@actions/exec wrapper to get listener data value as return value.

Usage

const exec = require('actions-exec-listener');
// instead of
// const exec = require('@actions/exec');

const options = {};
options.cwd = './lib';
const { stdoutStr: myOutput, stderrStr: myError } = await exec.exec('node', ['index.js', 'foo=bar'], options);

Using @actions/exec

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

let myOutput = '';
let myError = '';

const options = {};
options.listeners = {
  stdout: (data: Buffer) => {
    myOutput += data.toString();
  },
  stderr: (data: Buffer) => {
    myError += data.toString();
  }
};
options.cwd = './lib';

await exec.exec('node', ['index.js', 'foo=bar'], options);

Above code from actions/toolkit repository

Install

$ npm install actions-exec-listener @actions/exec
$ # or
$ yarn add actions-exec-listener @actions/exec

Description

It can be used in the same way as @actions/exec, except for the return value.

Return values

require('actions-exec-listener').exec returns object containing the below keys.

  • Extended from @actions/exec
    • stdout Buffer
    • stderr Buffer
    • stdline string
    • errline string
    • debug string
  • Added by actions-exec-listener
    • stdoutStr
      • Returned value of stdout.toString().
    • stderrStr
      • Returned value of stderr.toString().

Contribution

PRs are accepted.

If you are having trouble or feature request, post new issue.