-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap
More file actions
executable file
·57 lines (47 loc) · 1.61 KB
/
bootstrap
File metadata and controls
executable file
·57 lines (47 loc) · 1.61 KB
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
/**
* bootstrap - jtools
* handles args for jtools
* Copyright (C) 2016 VVBKA.
*/
'use strict';
let path = require('path'),
cli = require('cli'),
main = require('./bin/' + path.basename(process.argv[1]) + '.js'),
fs = require('fs'),
Handlebars = require('handlebars'),
extend = require('jquery-extend');
// parse the arguments for this specific command
cli.parse(main[0]);
// read in the default config file
fs.readFile(path.resolve(__dirname, '.jtoolsrc'), 'utf8', function (err, data) {
if (err) {
console.error(err);
process.exit(-1);
} else {
let config = require('rc')('jtools', JSON.parse(data), {});
delete config._;
delete config.configs;
delete config.config;
config.compile = function (more) {
more = more || {};
var tmp = {}, i;
for (i in config) {
if (config.hasOwnProperty(i) && typeof config[i] !== 'function') {
if (config[i].indexOf('{{') !== -1) {
let data = JSON.parse(JSON.stringify(config));
extend(data, tmp, more);
data.copyright_year = (new Date()).getFullYear();
tmp[i] = Handlebars.compile(config[i])(data);
} else {
tmp[i] = config[i];
}
}
}
return tmp;
};
cli.main(function (args, opts) {
main[1].call(this, args, opts, config);
});
}
});