mirror of
https://github.com/Swatinem/rust-cache.git
synced 2025-08-14 20:55:13 +00:00
Ensure consistency of main and post configuration by storing and restoring it from state, which in turn ensures cache key stability. Also: * Fixed some typos. * Use core.error for logging errors. * Fix inverted condition on cache-all-crates. Reverts: #138 Fixes #140
31 lines
644 B
TypeScript
31 lines
644 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(`Command failed: ${cmd} ${args.join(" ")}`);
|
|
core.error(stderr);
|
|
throw e;
|
|
}
|
|
return stdout;
|
|
}
|