An actions-kit command execution library
npm install @actions-kit/exec

A command execution library of Actions Kit, an additional toolkit for developing GitHub Actions.
``sh`
npm install @actions-kit/exec
Use run(command, args...) to run a command.
`js
const exec = require('@actions-kit/exec');
await exec.run("node", "index.js");
`
It will returns a RunResult object which contains an exit code of the command run.`jsFailed with exit code: ${res.code}
const res = await exec.run("node", "-c", "index.js");
if (!res.isOk()) {
console.log();`
}
Use output(command, args...) to run a command and get the output. It will returns an OutputResult object which contains an exit code and the log output of the command run.`js
const exec = require('@actions-kit/exec');
const res = await exec.output("node", "--version");
if (!res.isOk()) {
console.log(Failed with exit code: ${res.code});Node version: ${res.output}
} else {
console.log();`
}
Use runSilently(command, args...) to run a command silently without printing anything to the console.`js
const exec = require('@actions-kit/exec');
await exec.runSilently("node", "-c", "index.js");
`
Or use outputSilently(command, args...) to run a command and get the output silently without printing anything to the console.`jsNode version: ${res.output}
const res = await exec.outputSilently("node", "--version");
console.log();`
Construct a command helper using Command class to simplify the command run.`js
const exec = require('@actions-kit/exec');
const node = new exec.Command("node", "-e");
await node.run("process.exit();");
`
All command run functions are available in the Command class and are behaving the same.`js
await node.runSilently("process.exit();");
const res = node.output("console.log('Hello world!');");
console.log(output: ${res.output});``
This project is licensed under the terms of the MIT License.
Copyright © 2023 Alfi Maulana