Skip to content

Commit bd42cda

Browse files
committed
Avoid process.exit, throw and catch errors
1 parent 3f53a2b commit bd42cda

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

lib/config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var formatPath = function(path) {
1414
}
1515
if (!fs.existsSync(path) && !fs.existsSync(path.split('?')[0])) {
1616
console.error('Test path: ' + path + ' is invalid.');
17-
process.exit(1);
17+
throw new Error('Test path: ' + path + ' is invalid.');
1818
}
1919
return path;
2020
};
@@ -30,12 +30,13 @@ exports.config = function(config_path) {
3030
} catch (e) {
3131
if (e.code === 'MODULE_NOT_FOUND') {
3232
logger.info('Configuration file `browserstack.json` is missing.');
33+
throw new Error('Configuration file `browserstack.json` is missing.');
3334
} else {
3435
logger.info('Invalid configuration in `browserstack.json` file');
3536
logger.info(e.message);
3637
logger.info(e.stack);
38+
throw new Error('Invalid configuration in `browserstack.json` file');
3739
}
38-
process.exit(1);
3940
}
4041

4142
var package_json = {};
@@ -79,7 +80,7 @@ exports.config = function(config_path) {
7980
['username', 'key', 'browsers', 'test_path'].forEach(function(param) {
8081
if (typeof config[param] === 'undefined' && typeof that[param] === 'undefined') {
8182
console.error('Configuration parameter `%s` is required.', param);
82-
process.exit(1);
83+
throw new Error('Configuration parameter `%s` is required.', param);
8384
}
8485
});
8586

lib/configParser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var ConfigParser = {
1313
if(error) {
1414
logger.info('Error getting browsers list from BrowserStack');
1515
logger.info(error);
16-
process.exit(1);
16+
throw new Error('Error getting browsers list from BrowserStack');
1717
}
1818
ConfigParser.bsBrowsers = browsers;
1919
for (var key in browser_config) {

lib/local.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var Tunnel = function Tunnel(key, port, uniqueIdentifier, config, callback) {
2424
if (stdout.indexOf('Error') >= 0 || error) {
2525
logger.debug('[%s] Tunnel launching failed', new Date());
2626
logger.debug(stdout);
27-
process.exit('SIGINT');
27+
throw new Error('[%s] Tunnel launching failed', new Date());
2828
}
2929
});
3030

@@ -35,7 +35,7 @@ var Tunnel = function Tunnel(key, port, uniqueIdentifier, config, callback) {
3535
setTimeout(function() {
3636
if (!running) {
3737
logger.error('BrowserStackLocal failed to launch within 30 seconds.');
38-
process.exit(1);
38+
throw new Error('BrowserStackLocal failed to launch within 30 seconds.');
3939
}
4040
}, 30 * 1000);
4141

@@ -181,7 +181,7 @@ var Tunnel = function Tunnel(key, port, uniqueIdentifier, config, callback) {
181181
}, 100);
182182
}).on('error', function(e) {
183183
logger.info('Got error while downloading binary: ' + e.message);
184-
process.exit('SIGINT');
184+
throw new Error('Got error while downloading binary: ' + e.message);
185185
});
186186
});
187187
});

lib/server.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ exports.Server = function Server(bsClient, workers, config, callback) {
313313

314314
logger.trace('[%s] _report: checkAndTerminateWorker: all tests done', worker.id, config.status && 'with failures');
315315
callback(null, 'All Tests Done');
316-
//process.exit('SIGTERM');
317316
}
318317
});
319318
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "browserstack-runner",
33
"description": "A command line interface to run browser tests over BrowserStack",
4-
"version": "0.4.5",
4+
"version": "0.4.4",
55
"homepage": "https://github.com/browserstack/browserstack-runner",
66
"repository": {
77
"type": "git",

0 commit comments

Comments
 (0)