mirror of
https://github.com/Swatinem/rust-cache
synced 2025-06-19 06:43:41 +00:00
rewrite it all
This commit is contained in:
parent
5df06440c6
commit
6ed4c28a7c
8 changed files with 527 additions and 466 deletions
29
src/utils.ts
Normal file
29
src/utils.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue