/
index.js
executable file
·89 lines (68 loc) · 1.3 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env node
var
optimist = require('optimist');
var
Bundler = require('./lib/Bundler.js');
/**
* Application object
*/
var App = {};
/**
* Log to console
*/
App.log = function(msg) {
if(App.conf.verbose) {
console.log('jade-bundler: ' + msg);
}
}
/**
* Log error to console
*/
App.error = function(msg) {
if(App.conf.verbose) {
console.error('jade-bundler: ' + msg);
}
}
/**
* Command line configuration
*/
App.conf = optimist
.usage('Usage: jade-bundler [-u] [-p=<path>] [-o=<path>] <files>')
.default({
'u' : false,
'p' : './',
'object' : 'window.JADETemplates',
'o' : undefined,
'v' : false,
'd' : false
})
.string('o')
.alias('o', 'out')
.describe('o', 'Output file')
.boolean('u')
.alias('u', 'uglify')
.describe('u', 'Compress with ugilfy.js')
.boolean('v')
.alias('v', 'verbose')
.describe('v', 'Output system information')
.boolean('d')
.alias('d', 'debug')
.describe('d', 'Add debug information')
.string('p')
.alias('p', 'path')
.describe('p', 'Root dir path')
.string('object')
.describe('Hash which contains templates')
.argv;
/**
* Templates list
*/
App.templates = App.conf._;
if(App.templates.length == 0) {
optimist.showHelp();
process.exit();
}
/**
* Bundler instance
*/
App.bundler = Bundler(App, App.templates);