fix: create writestream before http call

This commit is contained in:
Tom Hu 2023-11-10 08:27:28 +11:00
parent 0cb9213bc4
commit affbcb165a
No known key found for this signature in database
GPG key ID: 79155678363963D2
3 changed files with 6 additions and 20 deletions

View file

@ -23,16 +23,10 @@ try {
const platform = getPlatform(os);
const filename = path.join( __dirname, getUploaderName(platform));
const filePath = fs.createWriteStream(filename);
https.get(getBaseUrl(platform, uploaderVersion), (res) => {
// Image will be stored at this path
if (fs.existsSync(filename)) {
core.info('IT EXISTS');
} else {
core.info('IT DOESNT EXIST');
}
const filePath = fs.createWriteStream(filename);
res.pipe(filePath);
filePath
.on('error', (err) => {
core.info(`${console.trace()}`);
@ -68,7 +62,6 @@ try {
unlink();
});
});
res.pipe(filePath);
});
} catch (err) {
setFailure(`Codecov: Encountered an unexpected error ${err.message}`, failCi);