Skip to content

Commit 4bbe6b3

Browse files
authored
Merge pull request #215 from shazron/no_lib_exit
Remove process.exit when simctl prerequisite does not pass
2 parents ee3594f + ebaea0b commit 4bbe6b3

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ios-sim",
3-
"version": "5.1.0",
3+
"version": "6.0.0",
44
"preferGlobal": "true",
55
"description": "launch iOS apps into the iOS Simulator from the command line (Xcode 7.0+)",
66
"main": "ios-sim.js",

spec/lib.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ describe('lib end-to-end', function() {
5151
});
5252
})
5353

54-
// it('', function(done) {
55-
// });
54+
it('init should not process.exit when called as a lib', function() {
55+
var code = lib.init();
56+
expect(!isNaN(code)).toBe(true);
57+
});
5658
});

src/cli.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ var nopt;
3737
function init() {
3838
try {
3939
nopt = require('nopt');
40-
command_lib.init();
40+
var code = command_lib.init();
41+
if (code !== 0) {
42+
process.exit(code);
43+
}
4144
} catch (e) {
4245
console.error(
4346
'Please run npm install from this directory:\n\t' +

src/commands.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var path = require('path'),
3131
var command_lib = {
3232

3333
init: function() {
34-
lib.init();
34+
return lib.init();
3535
},
3636

3737
//jscs:disable disallowUnusedParams

src/lib.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,13 @@ var lib = {
274274
var output = simctl.check_prerequisites();
275275
if (output.code !== 0) {
276276
console.error(output.output);
277-
process.exit(2);
278277
}
279278

280279
if (!bplist) {
281280
bplist = require('bplist-parser');
282281
}
282+
283+
return output.code;
283284
},
284285

285286
//jscs:disable disallowUnusedParams

0 commit comments

Comments
 (0)