coworker-cli
Version:
Template path parser for 58.com velocity templates, which can read your target template and output the main template path.
26 lines (24 loc) • 692 B
JavaScript
/**
* Created by wangyujing on 11/17/15.
*/
var fs = require('fs');
var findParse = require('./findParse');
var go = require('./globalObject');
module.exports = function (filepath) {
if (fs.existsSync(filepath)) {
var file = fs.readFileSync(filepath, 'utf8');
var parses = findParse(file);
var pathPrefix = filepath.split('views')[0];
if (parses) {
parses.forEach(function (p) {
p = pathPrefix + p;
if (!go[p]) {
go[p] = [];
}
if (go[p].indexOf(filepath) < 0) {
go[p].push(filepath);
}
});
}
}
};