Skip to content

Commit 75d368e

Browse files
committed
Delete file in catch as well
1 parent d1b1bea commit 75d368e

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

bin/commands/runs.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ module.exports = function run(args) {
1212
return runCypress(args);
1313
}
1414

15+
function deleteZip() {
16+
fs.unlink(config.fileName, function (err) {
17+
if(err) {
18+
logger.log(Constants.userMessages.ZIP_DELETE_FAILED);
19+
} else {
20+
logger.log(Constants.userMessages.ZIP_DELETED);
21+
}
22+
});
23+
}
24+
1525
function runCypress(args) {
1626
let bsConfigPath = process.cwd() + args.cf;
1727
logger.log(`Reading config from ${args.cf}`);
@@ -30,25 +40,19 @@ function runCypress(args) {
3040
}).catch(function (err) {
3141
// Build creation failed
3242
logger.error(Constants.userMessages.BUILD_FAILED)
33-
}).finally(function() {
34-
// Delete zip file from local storage
35-
fs.unlink(config.fileName, function (err) {
36-
if(err) {
37-
logger.log(Constants.userMessages.ZIP_DELETE_FAILED);
38-
} else {
39-
logger.log(Constants.userMessages.ZIP_DELETED);
40-
}
41-
});
4243
});
4344
}).catch(function (err) {
4445
// Zip Upload failed
4546
logger.error(err)
4647
logger.error(Constants.userMessages.ZIP_UPLOAD_FAILED)
48+
}).finally(function (params) {
49+
deleteZip();
4750
});
4851
}).catch(function (err) {
4952
// Zipping failed
5053
logger.error(err)
5154
logger.error(Constants.userMessages.FAILED_TO_ZIP)
55+
deleteZip();
5256
});
5357
}).catch(function (err) {
5458
// browerstack.json is not valid

0 commit comments

Comments
 (0)