From 37a055c776a8820c3deb24691e5041eb4874771e Mon Sep 17 00:00:00 2001 From: dogbert911 <98908967+dogbert911@users.noreply.github.com> Date: Thu, 31 Mar 2022 21:25:35 +0300 Subject: [PATCH 1/2] 'online' logs from subprocess --- with-post-step/main.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/with-post-step/main.js b/with-post-step/main.js index cdef47a..6fa5332 100644 --- a/with-post-step/main.js +++ b/with-post-step/main.js @@ -26,14 +26,13 @@ * ================================================================================================================== */ const { exec } = require("child_process"); -function run(cmd) { - exec(cmd, (error, stdout, stderr) => { - if ( stdout.length !== 0 ) { console.log(`${stdout}`); } - if ( stderr.length !== 0 ) { console.error(`${stderr}`); } - if (error) { - process.exitCode = error.code; - console.error(`${error}`); - } +function run(cmdline) { + var args = cmdline.split(' '); + const cmd = args.shift(); + + const subprocess = spawn(cmd, args, { stdio: 'inherit' }); + subprocess.on('exit', (exit_code) => { + process.exitCode = exit_code }); } From 2305ab20278915b0dd130c118098ff030dc78e2d Mon Sep 17 00:00:00 2001 From: dogbert911 <98908967+dogbert911@users.noreply.github.com> Date: Thu, 31 Mar 2022 22:02:40 +0300 Subject: [PATCH 2/2] Fix linter --- with-post-step/main.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/with-post-step/main.js b/with-post-step/main.js index 6fa5332..0fa6d9e 100644 --- a/with-post-step/main.js +++ b/with-post-step/main.js @@ -24,15 +24,15 @@ * * https://github.com/docker/login-action/issues/72 * * * https://github.com/actions/runner/issues/1478 * * ================================================================================================================== */ -const { exec } = require("child_process"); +const { spawn } = require("child_process"); function run(cmdline) { - var args = cmdline.split(' '); + var args = cmdline.split(" "); const cmd = args.shift(); - const subprocess = spawn(cmd, args, { stdio: 'inherit' }); - subprocess.on('exit', (exit_code) => { - process.exitCode = exit_code + const subprocess = spawn(cmd, args, { stdio: "inherit" }); + subprocess.on("exit", (exitCode) => { + process.exitCode = exitCode; }); }