-
Notifications
You must be signed in to change notification settings - Fork 7
/
cli
62 lines (50 loc) · 1.24 KB
/
cli
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env node
'use strict';
process.title = 'tsconfig-glob';
var resolve = require('resolve');
var exit = require('exit');
resolve('tsconfig-glob', {
basedir: process.cwd()
}, function (error, localCli) {
var cli;
if (error) {
cli = require('./index');
} else {
cli = require(localCli);
}
var args = process.argv.slice(2),
indentOptionIndex = args.indexOf('-i'),
indent = 4,
empty = false;
if (indentOptionIndex === -1) {
indentOptionIndex = args.indexOf('--indent');
}
if (indentOptionIndex > -1) {
indent = Number(args.splice(indentOptionIndex, 2)[1])
}
var emptyOptionIndex = args.indexOf('--empty');
if (emptyOptionIndex > -1) {
args.splice(emptyOptionIndex);
empty = true;
}
var cwd = process.cwd();
try {
cli({
args: args,
indent: indent,
configPath: args[0] || '.',
cwd: cwd,
empty: empty
}, function(err) {
if(!!err) {
console.error(err);
exit(1);
return;
}
exit(0);
});
} catch (e) {
console.error(e);
exit(1);
}
});