-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
75 lines (60 loc) · 1.75 KB
/
index.js
File metadata and controls
75 lines (60 loc) · 1.75 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
var path = require('path');
var fs = require('fs');
var fis = require('./fis');
var fisOptions = {};
module.exports = Builder;
function Builder(options) {
if (!(this instanceof Builder)) return new Builder(options);
this.initialize(options);
}
Builder.prototype.initialize = function(options) {
var paths = options.paths || [];
if (!Array.isArray(paths)) {
paths = [paths];
}
this.paths = paths;
};
Builder.prototype.run = function(done) {
//fisOptions = {paths: []};
fisOptions.paths = this.paths || [];
fisOptions.clean = 1;
fisOptions.pack = 1;
//fisOptions.verbose = 1;
fis.run(fisOptions);
fis.getFileRet(function(ret) {
done && done(ret);
});
};
fis.project.getSource = function() {
var rootSrc, root = rootSrc = fis.project.getProjectPath(),
source = {},
project_exclude = new RegExp(
'^' + fis.util.escapeReg(root + '/') +
'(?:output\\b|fis-[^\\/]+$)',
'i'),
include = fis.config.get('project.include'),
exclude = fis.config.get('project.exclude');
var oldNamespace = fis.config.get('namespace') || '';
readFile(root);
var paths = fisOptions.paths, namespace = '';
for (var i = 0; i < paths.length; i++) {
root = paths[i];
namespace = root.substr(path.dirname(root).length + 1);
//console.log('namespace: ' + namespace + ' root:' + root);
//fis.config.set('namespace', namespace);
fis.project.setProjectRoot(path.dirname(root));
readFile(root);
}
function readFile(root) {
fis.util.find(root, null, project_exclude).forEach(function(file) {
file = fis.file(file);
file.root = root;
if (file.release && fis.util.filter(file.subpath, include, exclude)) {
source[file.subpath] = file;
}
});
}
//fis.config.set('namespace', oldNamespace);
fis.project.setProjectRoot(rootSrc);
return source;
};