-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcli.js
executable file
·40 lines (33 loc) · 862 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
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env node
var path = require('path');
var arg = process.argv[2];
if (!arg) {
console.error('nnode should be called with a js file as an argument');
process.exit(-1);
}
require('@babel/polyfill');
var config = require('./config')(undefined, arg);
require('@babel/register')(config);
if (arg === '-v' || arg === '--version') {
console.log(require('./package.json').version);
process.exit(0);
}
process.argv.shift();
if (arg === '--transpile') {
var transpile = require('./transpile-directory');
transpile();
process.exit(0);
}
if (arg === '--tsconfig') {
require('./create-tsconfig');
process.exit(0);
}
try {
require(path.resolve(arg));
} catch (e) {
if (e.message === 'Cannot find module \'flow-runtime\'') {
console.error('Missing flow-runtime. Run `npm install flow-runtime`');
process.exit(-1);
}
throw e;
}