fix: does the file exist?

This commit is contained in:
Tom Hu 2023-11-10 10:26:07 +11:00
parent affbcb165a
commit 4ec3acecb4
No known key found for this signature in database
GPG key ID: 79155678363963D2
3 changed files with 16 additions and 7 deletions

View file

@ -23,18 +23,22 @@ try {
const platform = getPlatform(os);
const filename = path.join( __dirname, getUploaderName(platform));
const filePath = fs.createWriteStream(filename);
https.get(getBaseUrl(platform, uploaderVersion), (res) => {
const filePath = fs.createWriteStream(filename);
res.pipe(filePath);
filePath
.on('error', (err) => {
core.info(`${console.trace()}`);
core.info(`Stack: ${err.stack}`);
if (fs.existsSync(filename)) {
core.info('IT EXISTS');
} else {
core.info('IT DOESNT EXIST');
}
setFailure(
`Codecov:Failed to write uploader binary: ${err.message}\n${err}`,
true,
);
core.info(`${console.trace()}`);
}).on('finish', async () => {
filePath.close();