-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
59 lines (55 loc) · 2.01 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
require('date-utils');
var fs = require('fs-extra');
var syspath = require('path');
//var url = require('url')
//var querystring = require('querystring')
//var child_process = require('child_process')
var baselib = syspath.join(module.parent.filename, '../')
var utils = require(syspath.join(baselib, 'util'));
var webserver = require('./lib/webserver'); //webserver测试 fekit hf -s
var hfpackage = require('./lib/package'); //直接打包fekit hf
var isDebug = false;
var vermap = versionMapping = false;
exports.usage = "处理header&footer项目编译使用";
exports.set_options = function(optimist) {
optimist.alias('s', 'server')
optimist.describe('s', '启动hf测试web服务, 如 fekit hf -s')
optimist.alias('d', 'debug')
return optimist.describe('d', '启用调试模式,不会压缩代码,该参数优先级高于-m')
}
exports.run = function(options) {
isDebug = !!options.debug;
options.hfPath = process.cwd();
if (options.server){
console.log('服务已经启动,请访问http://127.0.0.1:'+options.p+'\n使用ctrl+c结束')
return webserver.start(options);
}
else {
if (!utils.path.exists("./ver/versions.mapping")) {
throw new Error('未获取到./ver/versions.mapping 请确认qzz tagname是否正确');
}
loadVersionMapping()
options.vermap = vermap || false
hfpackage.execute(options);
utils.logger.log('done.')
return;
}
}
//加载versions.mapping文件,在使用qdr发布时qdr会自动下载此文件
function loadVersionMapping() {
var verfile = utils.path.exists("./ver/versions.mapping") ? utils.file.io.read("./ver/versions.mapping") : '';
var arr = verfile.split('\n');
if (arr.length > 0) {
vermap = {};
}
for (var i in arr) {
var item = arr[i];
if (item.indexOf('#') > -1) {
var result = item.split('#');
if (result.length > 0) {
vermap[result[0]] = result[1];
}
}
}
return vermap;
}