rust-cache/src/utils.ts
Steven Hartland ad97570a01
fix: cache key stability (#142)
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
2023-05-18 22:48:40 +02:00

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;
}