Skip to content

Commit

Permalink
Merge pull request #34 from WyriHaximus/use-async-exec-to-run-passed-…
Browse files Browse the repository at this point in the history
…script

Use async exec to run passed script
  • Loading branch information
WyriHaximus authored Jul 31, 2021
2 parents b635a10 + 504518a commit c7fc7ff
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
async function main() {
const homedir = require('os').homedir();
const fs = require('fs');
const {execFileSync} = require('child_process');
const {execFile} = require('child_process');
const tmp = require('tmp');
const {waitFile} = require('wait-file');

Expand Down Expand Up @@ -44,10 +44,24 @@ async function main() {

try {
console.log("\033[36mExecuting helm\033[0m");
const result = execFileSync(execShFile.name).toString();
console.log(result);
result = await new Promise((resolve, reject) => {
const process = execFile(execShFile.name);
process.stdout.on('data', console.log);
process.stderr.on('data', console.log);
let result = '';
process.stdout.on('data', (data) => result += data);
process.stderr.on('data', (data) => result += data);
process.on('exit', (code) => {
if (code === 0) {
resolve(result);
} else {
reject(result);
}
});
});
console.log('::set-output name=helm_output::' + result.split('%').join('%25').split('\n').join('%0A').split('\r').join('%0D'));
} catch (error) {
console.error(error);
process.exit(1);
} finally {
console.log("\033[36mCleaning up: \033[0m");
Expand Down

0 comments on commit c7fc7ff

Please sign in to comment.