-
Notifications
You must be signed in to change notification settings - Fork 165
/
options.js
60 lines (53 loc) · 1.14 KB
/
options.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
module.exports = options;
var minimist = require('minimist');
function options(args) {
var argv = minimist(args, {
boolean: [ // flags
'version',
'help',
'debug',
'verbose',
'noimages',
'nocompress',
'nosvg',
'skip-absolute-urls',
'videos',
'inlinemin',
'preserve-comments',
'iesafe',
],
string: [ // options
'encoding',
],
alias: {
images: 'noimages', // legacy support
V: 'version',
h: 'help',
d: 'debug',
v: 'verbose',
i: 'noimages',
n: 'nocompress',
e: 'encoding',
s: 'nosvg',
o: 'videos',
m: 'inlinemin',
H: 'header',
},
});
// copy across specific options
if (argv.nocompress) {
argv.compressCSS = false;
argv.compressJS = false;
argv.collapseWhitespace = false;
}
if (argv['preserve-comments']) {
argv.preserveComments = true;
}
if (argv['skip-absolute-urls']) {
argv.skipAbsoluteUrls = true;
}
argv.images = !argv.noimages;
argv.useStdin = !process.stdin.isTTY;
argv.verbose = argv.verbose || !process.stdout.isTTY;
return argv;
}