2015-08-03 20:45:58 -04:00
|
|
|
/**
|
|
|
|
* @dgService htmlFileShredder
|
|
|
|
* @description
|
|
|
|
*/
|
|
|
|
module.exports = function fileShredder(log, regionExtractor) {
|
|
|
|
return {
|
|
|
|
name: 'fileShredder',
|
|
|
|
|
|
|
|
getDocs: function (fileInfo) {
|
|
|
|
var commentMarkers;
|
|
|
|
switch (fileInfo.extension) {
|
|
|
|
case 'ts':
|
|
|
|
case 'js':
|
|
|
|
commentMarkers = ['//'];
|
|
|
|
break;
|
|
|
|
case 'html':
|
|
|
|
commentMarkers = ['<!--'];
|
|
|
|
break;
|
|
|
|
case 'css':
|
|
|
|
commentMarkers = ['/*'];
|
|
|
|
break;
|
2015-09-12 03:28:01 -04:00
|
|
|
case 'json':
|
|
|
|
break;
|
2015-08-03 20:45:58 -04:00
|
|
|
default:
|
|
|
|
return [];
|
|
|
|
}
|
2015-09-18 22:51:10 -04:00
|
|
|
var docs;
|
|
|
|
// log.info("fileShredder processing: " + fileInfo.relativePath);
|
2015-09-12 03:28:01 -04:00
|
|
|
if (commentMarkers) {
|
2015-09-18 22:51:10 -04:00
|
|
|
docs = regionExtractor(fileInfo.content, commentMarkers);
|
2015-09-12 03:28:01 -04:00
|
|
|
} else {
|
2015-09-18 22:51:10 -04:00
|
|
|
docs = [ { content: fileInfo.content } ];
|
2015-09-12 03:28:01 -04:00
|
|
|
}
|
2015-09-18 22:51:10 -04:00
|
|
|
if (docs.length) {
|
|
|
|
log.info("shredded file: " + fileInfo.relativePath);
|
|
|
|
}
|
|
|
|
return docs;
|
2015-08-03 20:45:58 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|