Skip to content

Commit 79220e7

Browse files
committed
Fix CLI rejection output for tests and standard usage
1 parent 8fe7ffd commit 79220e7

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

index.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ function version(program) {
4040

4141
const targets = []
4242
.concat(programOpts.target, env.target)
43-
.filter(function(target) {
44-
return typeof target !== 'undefined';
45-
});
43+
.filter(Boolean);
4644

4745
const appPkg = require(path.join(programOpts.cwd, 'package.json'));
46+
var android;
47+
var ios;
4848

49-
const android = new Promise(function(resolve, reject) {
50-
if (!targets.length || targets.indexOf('android') > -1) {
49+
if (!targets.length || targets.indexOf('android') > -1) {
50+
android = new Promise(function(resolve, reject) {
5151
fs.stat(programOpts.android, function(err) {
5252
if (err) {
5353
reject([
@@ -80,11 +80,11 @@ function version(program) {
8080
resolve();
8181
}
8282
});
83-
}
84-
});
83+
});
84+
}
8585

86-
const ios = new Promise(function(resolve, reject) {
87-
if (!targets.length || targets.indexOf('ios') > -1) {
86+
if (!targets.length || targets.indexOf('ios') > -1) {
87+
ios = new Promise(function(resolve, reject) {
8888
fs.stat(programOpts.ios, function(err) {
8989
if (err) {
9090
reject([
@@ -146,10 +146,11 @@ function version(program) {
146146
resolve();
147147
}
148148
});
149-
}
150-
});
149+
});
150+
}
151151

152-
return pSettle([android, ios]).then(function(result) {
152+
return pSettle([android, ios].filter(Boolean))
153+
.then(function(result) {
153154
const errs = result
154155
.filter(function(item) {
155156
return item.isRejected;
@@ -173,11 +174,11 @@ function version(program) {
173174
program.outputHelp();
174175
}
175176

176-
throw new Error('╻\n┏━━━━━━━━┛\n╹\n' + errs.map(function(errGrp, index) {
177+
throw errs.map(function(errGrp, index) {
177178
return errGrp.map(function(err) {
178179
return err.text;
179-
}).join('\n');
180-
}).join('\n'));
180+
}).join(', ');
181+
}).join('; ');
181182
}
182183

183184
const gitCmdOpts = {
@@ -208,7 +209,10 @@ function version(program) {
208209
return child.execSync('git log -1 --pretty=%H', gitCmdOpts).toString();
209210
})
210211
.catch(function(err) {
211-
console.error(err);
212+
if (process.env.RNV_ENV === 'ava') {
213+
console.error(err);
214+
}
215+
212216
process.exit(1);
213217
});
214218
}

test/helpers/versionTempWithCLI.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ const child = require('child_process');
77
function versionTempWithCLI(params) {
88
const versionProcess = child.spawnSync(
99
'node',
10-
[require.resolve('../../cli')].concat(params).filter(Boolean)
10+
[require.resolve('../../cli')].concat(params).filter(Boolean),
11+
{
12+
env: Object.assign({}, process.env, {
13+
RNV_ENV: 'ava'
14+
})
15+
}
1116
);
1217

1318
if (versionProcess.status > 0) {

0 commit comments

Comments
 (0)