feat: log executed command

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>
This commit is contained in:
Alfi Maulana
2024-11-23 14:02:18 +07:00
parent c7ba931617
commit 7ad4029dc8
3 changed files with 31 additions and 1 deletions

11
dist/action.mjs generated vendored
View File

@@ -50,6 +50,16 @@ function logError(err) {
const message = err instanceof Error ? err.message : String(err);
process.stdout.write(`::error::${message}${os.EOL}`);
}
/**
* Logs a command along with its arguments in GitHub Actions.
*
* @param command - The command to log.
* @param args - The arguments of the command.
*/
function logCommand(command, ...args) {
const message = [command, ...args].join(" ");
process.stdout.write(`[command]${message}${os.EOL}`);
}
/**
* Executes a command with the given arguments.
@@ -62,6 +72,7 @@ function logError(err) {
*/
async function exec(command, args) {
return new Promise((resolve, reject) => {
logCommand(command, ...args);
const proc = spawn(command, args, {
stdio: ["ignore", "inherit", "inherit"],
});