From efb157518c0d13d12fa70fcebb0828cffbeee4ec Mon Sep 17 00:00:00 2001 From: Naveenraj M Date: Mon, 30 Mar 2020 04:07:25 +0530 Subject: [PATCH] using child process to get o/p --- lib/main.js | 23 ++++++++++++----------- src/main.ts | 27 +++++++++++++-------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/main.js b/lib/main.js index 3a28fca..083cb6d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -13,6 +13,7 @@ const github = require('@actions/github'); const exec = require('@actions/exec'); const io = require('@actions/io'); const download_tar = require('./download-release-archive'); +const cp = require('child_process'); function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -54,18 +55,18 @@ function run() { // If you want to upload yourself , need to write api call to upload as asset //core.setOutput("rpmPath", rpmPath) let myOutput = ''; - let myError = ''; - const options = {}; - options.listeners = { - stdout: (data) => { - myOutput += data.toString(); - }, - stderr: (data) => { - myError += data.toString(); + cp.exec('ls /github/home/rpmbuild/SRPMS/', (err, stdout, stderr) => { + if (err) { + //some err occurred + console.error(err); } - }; - options.cwd = '/github/home/rpmbuild/SRPMS/'; - yield exec.exec('ls', ['-C'], options); + else { + // the *entire* stdout and stderr (buffered) + console.log(`stdout: ${stdout}`); + myOutput = stdout; + console.log(`stderr: ${stderr}`); + } + }); core.setOutput("source_rpm_path", `/github/home/rpmbuild/SRPMS/${myOutput}`); // make option to upload source rpm } catch (error) { diff --git a/src/main.ts b/src/main.ts index 55f8fbc..d38295d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,6 +3,7 @@ const github = require('@actions/github'); const exec = require('@actions/exec'); const io = require('@actions/io'); const download_tar = require('./download-release-archive'); +const cp = require('child_process'); async function run() { try { @@ -60,21 +61,19 @@ async function run() { // actions/upload-release-asset // If you want to upload yourself , need to write api call to upload as asset //core.setOutput("rpmPath", rpmPath) + let myOutput = ''; - let myError = ''; - - const options: any = { }; - options.listeners = { - stdout: (data: Buffer) => { - myOutput += data.toString(); - }, - stderr: (data: Buffer) => { - myError += data.toString(); - } - }; - options.cwd = '/github/home/rpmbuild/SRPMS/'; - - await exec.exec('ls', [ '-C' ], options); + cp.exec('ls /github/home/rpmbuild/SRPMS/', (err, stdout, stderr) => { + if (err) { + //some err occurred + console.error(err) + } else { + // the *entire* stdout and stderr (buffered) + console.log(`stdout: ${stdout}`); + myOutput = stdout; + console.log(`stderr: ${stderr}`); + } + }); core.setOutput("source_rpm_path", `/github/home/rpmbuild/SRPMS/${myOutput}`); // make option to upload source rpm