-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.js
executable file
·57 lines (45 loc) · 1.36 KB
/
index.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
#!/usr/bin/env node
var program = require('commander')
var minifier = require('./src/minify')
if(require.main === module) {
var skip = []
program
.version(require('./package.json').version)
.option('-o, --output [file]', 'The output file')
.option('-t, --template [template]', 'A template for building the output file')
.option('-c, --clean', 'Deletes any files that resembles the template')
.option('-C, --clean-only', 'Same as `--clean`, but without minifying the files afterwards')
.option('-s, --skip <path-component>', 'Skip any files that contains this in the path')
.option('--no-comments', 'Remove license-style comments')
.usage('[--output file] path/to/input [...path/to/other/input]')
.on('skip', function(path) {
skip.push(path)
})
.parse(process.argv)
var inputs = program.args
var input
if(inputs.length == 1) {
input = inputs[0]
}
if(inputs.length == 0) {
program.parse(['bla', 'bla', '--help'])
process.exit()
}
if(skip.length) program.skip = skip
program.noComments = program.comments === false
minifier.on('error', function(msg) {
console.log(msg)
process.exit(1)
})
program.uglify = {
output: {
semicolons:false,
},
}
minifier.minify(input || inputs, program)
if(program.cleanOnly) {
return console.log('Minified files cleaned')
}
console.log('Minification complete')
}
module.exports = minifier