Skip to content

Commit

Permalink
Add error case for writestream
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrockhu committed Jul 14, 2021
1 parent 052070f commit ec2dbcb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
6 changes: 5 additions & 1 deletion dist/index.js
Expand Up @@ -7670,7 +7670,11 @@ try {
// Image will be stored at this path
var filePath = fs.createWriteStream(filename_1);
res.pipe(filePath);
filePath.on('finish', function () {
filePath
.on('error', function (err) {
src_core.setFailed('Codecov: Failed to write uploader binary: ' +
("" + err.message));
}).on('finish', function () {
filePath.close();
// TODO - validate step
fs.chmodSync(filename_1, '777');
Expand Down
30 changes: 18 additions & 12 deletions src/index.ts
Expand Up @@ -15,19 +15,25 @@ try {
// Image will be stored at this path
const filePath = fs.createWriteStream(filename);
res.pipe(filePath);
filePath.on('finish', () => {
filePath.close();
// TODO - validate step
fs.chmodSync(filename, '777');
filePath
.on('error', (err) => {
core.setFailed(
'Codecov: Failed to write uploader binary: ' +
`${err.message}`,
);
}).on('finish', () => {
filePath.close();
// TODO - validate step
fs.chmodSync(filename, '777');

exec.exec(filename, execArgs, options).catch((err) => {
core.setFailed(
'Codecov: Failed to properly upload: ' +
`${err.message}`,
);
return;
});
});
exec.exec(filename, execArgs, options).catch((err) => {
core.setFailed(
'Codecov: Failed to properly upload: ' +
`${err.message}`,
);
return;
});
});
});
} catch (err) {
core.setFailed(
Expand Down

0 comments on commit ec2dbcb

Please sign in to comment.