From c3f01090b04a4873b5d51167bd5cdb224ffcee96 Mon Sep 17 00:00:00 2001 From: Naveenraj M Date: Sun, 29 Mar 2020 20:26:18 +0530 Subject: [PATCH] async file write --- lib/download-release-archive.js | 7 ++++++- lib/main.js | 2 ++ src/download-release-archive.ts | 7 ++++++- src/main.ts | 3 ++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/download-release-archive.js b/lib/download-release-archive.js index 59b70f4..e5dbbf7 100644 --- a/lib/download-release-archive.js +++ b/lib/download-release-archive.js @@ -25,7 +25,12 @@ function download_archive(owner, repo, ref) { archive_format, ref }).then(({ data }) => { - fs.writeFileSync(tarFile, Buffer.from(data)); + fs.writeFile(tarFile, Buffer.from(data), function (err) { + if (err) { + return console.log(err); + } + console.log("The Tar file was saved!"); + }); }).catch(function (error) { console.log(error); }); diff --git a/lib/main.js b/lib/main.js index c5c6ce0..ce2d5c1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,6 +28,8 @@ function run() { console.log(`Hello ${specFile} from inside a container`); // Get repo files from /github/workspace/ yield exec.exec('ls -la /github/workspace'); + // Get repo files from /github/workspace/ + yield exec.exec('ls -la '); // Copy spec file from path specFile to /root/rpmbuild/SPECS/ yield io.cp('/github/workspace/cello.spec', '/root/rpmbuild/SPECS/'); // Get tar.gz file of release diff --git a/src/download-release-archive.ts b/src/download-release-archive.ts index 0db3181..46590a4 100644 --- a/src/download-release-archive.ts +++ b/src/download-release-archive.ts @@ -21,7 +21,12 @@ async function download_archive(owner, repo, ref ) { archive_format, ref }).then(( { data }) => { - fs.writeFileSync(tarFile, Buffer.from(data)); + fs.writeFile(tarFile, Buffer.from(data), function(err){ + if(err) { + return console.log(err); + } + console.log("The Tar file was saved!"); + }); }).catch( function(error){ console.log(error); }); diff --git a/src/main.ts b/src/main.ts index b5c27ed..c26a891 100644 --- a/src/main.ts +++ b/src/main.ts @@ -26,7 +26,8 @@ async function run() { // Get repo files from /github/workspace/ await exec.exec('ls -la /github/workspace'); - + // Get repo files from /github/workspace/ + await exec.exec('ls -la '); // Copy spec file from path specFile to /root/rpmbuild/SPECS/ await io.cp('/github/workspace/cello.spec', '/root/rpmbuild/SPECS/');