using child process to get o/p

This commit is contained in:
Naveenraj M
2020-03-30 04:07:25 +05:30
parent e9c1abc0c0
commit efb157518c
2 changed files with 25 additions and 25 deletions

View File

@ -13,6 +13,7 @@ const github = require('@actions/github');
const exec = require('@actions/exec'); const exec = require('@actions/exec');
const io = require('@actions/io'); const io = require('@actions/io');
const download_tar = require('./download-release-archive'); const download_tar = require('./download-release-archive');
const cp = require('child_process');
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
@ -54,18 +55,18 @@ function run() {
// If you want to upload yourself , need to write api call to upload as asset // If you want to upload yourself , need to write api call to upload as asset
//core.setOutput("rpmPath", rpmPath) //core.setOutput("rpmPath", rpmPath)
let myOutput = ''; let myOutput = '';
let myError = ''; cp.exec('ls /github/home/rpmbuild/SRPMS/', (err, stdout, stderr) => {
const options = {}; if (err) {
options.listeners = { //some err occurred
stdout: (data) => { console.error(err);
myOutput += data.toString();
},
stderr: (data) => {
myError += data.toString();
} }
}; else {
options.cwd = '/github/home/rpmbuild/SRPMS/'; // the *entire* stdout and stderr (buffered)
yield exec.exec('ls', ['-C'], options); 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 core.setOutput("source_rpm_path", `/github/home/rpmbuild/SRPMS/${myOutput}`); // make option to upload source rpm
} }
catch (error) { catch (error) {

View File

@ -3,6 +3,7 @@ const github = require('@actions/github');
const exec = require('@actions/exec'); const exec = require('@actions/exec');
const io = require('@actions/io'); const io = require('@actions/io');
const download_tar = require('./download-release-archive'); const download_tar = require('./download-release-archive');
const cp = require('child_process');
async function run() { async function run() {
try { try {
@ -60,21 +61,19 @@ async function run() {
// actions/upload-release-asset // actions/upload-release-asset
// If you want to upload yourself , need to write api call to upload as asset // If you want to upload yourself , need to write api call to upload as asset
//core.setOutput("rpmPath", rpmPath) //core.setOutput("rpmPath", rpmPath)
let myOutput = ''; let myOutput = '';
let myError = ''; cp.exec('ls /github/home/rpmbuild/SRPMS/', (err, stdout, stderr) => {
if (err) {
const options: any = { }; //some err occurred
options.listeners = { console.error(err)
stdout: (data: Buffer) => { } else {
myOutput += data.toString(); // the *entire* stdout and stderr (buffered)
}, console.log(`stdout: ${stdout}`);
stderr: (data: Buffer) => { myOutput = stdout;
myError += data.toString(); console.log(`stderr: ${stderr}`);
} }
}; });
options.cwd = '/github/home/rpmbuild/SRPMS/';
await exec.exec('ls', [ '-C' ], options);
core.setOutput("source_rpm_path", `/github/home/rpmbuild/SRPMS/${myOutput}`); // make option to upload source rpm core.setOutput("source_rpm_path", `/github/home/rpmbuild/SRPMS/${myOutput}`); // make option to upload source rpm