-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·28 lines (26 loc) · 962 Bytes
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env node
const cp = require('child_process');
const path = require('path');
const fs = require('fs');
const detoxPath = path.join(process.cwd(), 'node_modules/detox');
const detoxPackageJsonPath = path.join(detoxPath, 'package.json');
if (fs.existsSync(detoxPackageJsonPath)) {
// { shell: true } option seems to break quoting on windows? Otherwise this would be much simpler.
if (process.platform === 'win32') {
const result = cp.spawnSync(
'cmd',
['/c', path.join(process.cwd(), 'node_modules/.bin/detox.cmd')].concat(process.argv.slice(2)),
{ stdio: 'inherit' });
process.exit(result.status);
} else {
const result = cp.spawnSync(
path.join(process.cwd(), 'node_modules/.bin/detox'),
process.argv.slice(2),
{ stdio: 'inherit' });
process.exit(result.status);
}
} else {
console.log(detoxPackageJsonPath);
console.log("detox is not installed in this directory");
process.exit(1);
}