mirror of
https://github.com/threeal/cmake-action.git
synced 2025-09-13 19:17:21 +00:00
* test: enable strict TypeScript ESLint configuration Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com> * test: convert ESLint configuration to TypeScript Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com> --------- Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>
29 lines
1018 B
TypeScript
29 lines
1018 B
TypeScript
import { logCommand } from "gha-utils";
|
|
import { spawn } from "node:child_process";
|
|
|
|
/**
|
|
* Executes a command with the given arguments.
|
|
*
|
|
* The command is executed with `stdin` ignored and both `stdout` and `stderr` inherited by the parent process.
|
|
*
|
|
* @param command The command to execute.
|
|
* @param args The arguments to pass to the command.
|
|
* @returns A promise that resolves when the command exits successfully or rejects if it exits with a non-zero status code or encounters an error.
|
|
*/
|
|
export async function exec(command: string, args: string[]): Promise<void> {
|
|
return new Promise<void>((resolve, reject) => {
|
|
const proc = spawn(command, args, {
|
|
stdio: ["ignore", "inherit", "inherit"],
|
|
});
|
|
logCommand(proc.spawnfile, ...proc.spawnargs.splice(1));
|
|
proc.on("error", reject);
|
|
proc.on("close", (code: number) => {
|
|
if (code === 0) {
|
|
resolve();
|
|
} else {
|
|
reject(new Error(`Command exited with status code ${code.toString()}`));
|
|
}
|
|
});
|
|
});
|
|
}
|