angular-cn/public/doc-shredder/extractPathsReader.js

35 lines
744 B
JavaScript
Raw Normal View History

2015-08-10 14:17:02 -04:00
/**
* @dgService htmlFileShredder
* @description
*/
var path = require('canonical-path');
module.exports = function extractPathsReader(log) {
var rx = /\s*\+makeTabs\(\s*["'](.*?)["']\s*,\s*["'](.*?)["'].*?\)/g
return {
name: 'extractPathsReader',
getDocs: function (fileInfo) {
var content = fileInfo.content;
var refPaths = [];
var r;
while ((r = rx.exec(content)) !== null) {
var basePath = r[1];
var fileNames = r[2].split(',');
fileNames.forEach(function(fn) {
refPaths.push(path.join(basePath, fn));
})
}
if (refPaths.length) {
return [{
refPaths: refPaths
}];
} else {
return [];
}
}
}
}