-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathscripts.js
More file actions
26 lines (20 loc) · 770 Bytes
/
scripts.js
File metadata and controls
26 lines (20 loc) · 770 Bytes
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
const spawn = require('child_process').spawn;
const cpx = require('cpx');
const script = process.argv[2];
const arg = process.argv[3] || 'Login';
if(script === 'watch') {
const watcher = cpx.watch('./src/**/*.js', `examples/${arg}/node_modules/${process.env.npm_package_name}/src`);
watcher.on("watch-ready", () => { console.log('ready')});
watcher.on("remove", e => { console.log(e.path, '- removed')});
watcher.on('copy', e => {
console.log(e.srcPath, ' => ', e.dstPath);
});
}else {
let cmd = 'npm';
let params = ['run', script];
if (script === 'ios' || script === 'android') {
cmd = 'react-native';
params = [`run-${script}`];
}
spawn(cmd, params, {cwd: `./examples/${arg}`, stdio: 'inherit'});
}