mirror of https://github.com/actions/toolkit
![]() |
||
---|---|---|
.. | ||
__tests__ | ||
src | ||
LICENSE.md | ||
README.md | ||
RELEASES.md | ||
package-lock.json | ||
package.json | ||
tsconfig.json |
README.md
@actions/exec
Usage
Basic
You can use this package to execute tools in a cross platform way:
const exec = require('@actions/exec');
await exec.exec('node index.js');
Args
You can also pass in arg arrays:
const exec = require('@actions/exec');
await exec.exec('node', ['index.js', 'foo=bar']);
Capture stdout
To capture stdout (or stderr), use the function getExecOutput
.
const exec = require('@actions/exec');
const { stdout } = await exec.getExecOutput('node', ['index.js', 'foo=bar']);
Output/options
Specify other options:
const exec = require('@actions/exec');
const options = {
silent: true,
ignoreReturnCode: true,
};
await exec.exec('node', ['index.js', 'foo=bar'], options);
Exec tools not in the PATH
You can specify the full path for tools not in the PATH:
const exec = require('@actions/exec');
await exec.exec('"/path/to/my-tool"', ['arg1']);