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 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) {

View File

@ -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();
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}`);
}
};
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