src/index.js
function extractFilePaths(content, targetPath, opt, tagsRegExp) {
	const files = [];

	const tagMatches = content.match(tagsRegExp.start);
	if (tagMatches) {
		tagMatches.forEach(function (tagMatch) {
			const fileUrl = tagsRegExp.startex.exec(tagMatch)[1];
			const filePath = setFullPath(targetPath, opt.prefix + fileUrl);
			try {
				const fileContent = stripBomBuf(fs.readFileSync(filePath));
				files.push({
					file: new File({
						path: filePath,
						cwd: __dirname,
						base: path.resolve(__dirname, 'expected', path.dirname(filePath)),
						contents: fileContent
					}),
					tags: getRegExpTags(opt, fileUrl)
				});
			} catch (e) {
				if (opt.ignoreError) {
					log(colors.red(filePath + ' not found.'));
				} else {
					throw error(filePath + ' not found.');
				}
			}
			// reset the regex
			tagsRegExp.startex.lastIndex = 0;
		});
	}
	return files;
}
function extractFilePaths(content, targetPath, opt, tagsRegExp) {
	const files = [];

	const tagMatches = content.match(tagsRegExp.start);
	if (tagMatches) {
		tagMatches.forEach(function (tagMatch) {
			const fileUrl = tagsRegExp.startex.exec(tagMatch)[1];
			const filePath = setFullPath(targetPath, opt.prefix + fileUrl);
			try {
				const fileContent = stripBomBuf(fs.readFileSync(filePath));
				files.push({
					file: new File({
						path: filePath,
						cwd: __dirname,
						base: path.resolve(__dirname, 'expected', path.dirname(filePath)),
						contents: fileContent
					}),
					tags: getRegExpTags(opt, fileUrl)
				});
			} catch (e) {
				if (opt.ignoreError) {
					log(colors.red(filePath + ' not found.'));
				} else {
					throw error(filePath + ' not found.');
				}
			}
			// reset the regex
			tagsRegExp.startex.lastIndex = 0;
		});
	}
	return files;
}
function extractFilePaths ( content , targetPath , opt , tagsRegExp ) { const files = [ ] ; const tagMatches = content . match ( tagsRegExp . start ) ; if ( tagMatches ) { tagMatches . forEach ( function ( tagMatch ) { const fileUrl = tagsRegExp . startex . exec ( tagMatch ) [ 1 ] ; const filePath = setFullPath ( targetPath , opt . prefix + fileUrl ) ; try { const fileContent = stripBomBuf ( fs . readFileSync ( filePath ) ) ; files . push ( { file : new File ( { path : filePath , cwd : __dirname , base : path . resolve ( __dirname , 'expected' , path . dirname ( filePath ) ) , contents : fileContent } ) , tags : getRegExpTags ( opt , fileUrl ) } ) ; } catch ( e ) { if ( opt . ignoreError ) { log ( colors . red ( filePath + ' not found.' ) ) ; } else { throw error ( filePath + ' not found.' ) ; } } // reset the regex tagsRegExp . startex . lastIndex = 0 ; } ) ; } return files ; }
Parse content and get all partials to be injected
@param {String} content
@param {String} targetPath
@param {Object} opt
@param {Object} tagsRegExp
@returns {Array}
Parse content and get all partials to be injected