UNPKG

leasot

Version:

Parse and output TODOs and FIXMEs from comments in your files

27 lines (23 loc) 814 B
'use strict'; var commentsUtil = require('../utils/comments'); module.exports = function (params) { params = params || {}; var regex = commentsUtil.getRegex(params.customTags); var commentsRegex = new RegExp('^\\s*%' + regex + '$', 'mig'); return function parse(contents, file) { var comments = []; contents.split('\n').forEach(function (line, index) { var hashMatch = commentsRegex.exec(line); var comment; while (hashMatch) { comment = commentsUtil.prepareComment(hashMatch, index + 1, file); if (!comment) { break; } comments.push(comment); hashMatch = commentsRegex.exec(line); } }); return comments; }; };