mirror of
https://github.com/Swatinem/rust-cache
synced 2025-04-12 07:33:34 +00:00
30 lines
584 B
TypeScript
30 lines
584 B
TypeScript
import * as core from "@actions/core";
|
|
import * as exec from "@actions/exec";
|
|
|
|
export async function getCmdOutput(
|
|
cmd: string,
|
|
args: Array<string> = [],
|
|
options: exec.ExecOptions = {},
|
|
): Promise<string> {
|
|
let stdout = "";
|
|
let stderr = "";
|
|
try {
|
|
await exec.exec(cmd, args, {
|
|
silent: true,
|
|
listeners: {
|
|
stdout(data) {
|
|
stdout += data.toString();
|
|
},
|
|
stderr(data) {
|
|
stderr += data.toString();
|
|
},
|
|
},
|
|
...options,
|
|
});
|
|
} catch (e) {
|
|
core.error(stderr);
|
|
throw e;
|
|
}
|
|
return stdout;
|
|
}
|