Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return through.obj(function(file, enc, cb) {
if (file.isNull()) {
return cb(null, file);
}
if (file.isStream()) {
return cb(new PluginError(pluginName, 'Streaming not supported'));
}
// replace contents with requested reporter contents
if (file.todos && file.todos.length) {
const newContents = leasot.report(file.todos, reporter, reportOptions);
if (fileName) {
file.path = path.join(file.base, fileName);
}
file.contents = Buffer.from(newContents);
}
cb(null, file);
});
};
function reportTodos(cb) {
if (!firstFile) {
return cb();
}
const reporterContents = leasot.report(comments, reporter, reportOptions);
const todoFile = new Vinyl({
base: firstFile.base,
contents: Buffer.from(reporterContents),
cwd: firstFile.cwd,
path: path.join(firstFile.base, fileName),
});
// also pass along comments object for future reporters
todoFile.todos = comments;
cb(null, todoFile);
}
);