-
Notifications
You must be signed in to change notification settings - Fork 0
/
bin.js
executable file
·44 lines (40 loc) · 1.21 KB
/
bin.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env node
const { exec } = require('child_process');
const yargs = require('yargs');
const {
REACT_NATIVE_BUNDLE_COMMAND,
BUNDLE_UPDATER_CLI_COMMAND,
} = require('./constants');
const options = yargs
.usage('Usage: $0 [options] <apiKey> <branch> <version>')
.option('m', {
alias: 'comment',
describe: 'Add a comment to the bundle',
type: 'string',
default: '',
})
.demandCommand(3, 'You must provide the apiKey, branch and version')
.help('h')
.alias('h', 'help').argv;
const apiKey = options._[0];
const branch = options._[1];
const version = options._[2];
const comment = options.comment;
console.log(`Creating the bundle...`);
exec(REACT_NATIVE_BUNDLE_COMMAND, (error, stdout, stderr) => {
if (error) {
console.error(`Error during the first script execution: ${stderr}`);
process.exit(1);
} else {
const cliCommand = `${BUNDLE_UPDATER_CLI_COMMAND} ${apiKey} ${branch} ${version} -m "${comment}"`;
exec(cliCommand, (_error, _stdout, _stderr) => {
if (_error) {
console.error(`Error during the second script execution: ${_stderr}`);
process.exit(1);
} else {
console.log(`${_stdout}`);
process.exit(0);
}
});
}
});