Add option to override log output?
ansballard opened this issue · 0 comments
ansballard commented
Wondering if anyone else would be interested in an option to override the log function at https://github.com/klei/gulp-inject/blob/master/src/inject/index.js#L107. The quiet
option is nice, but I'm wrapping gulp and doing all the logging myself. It would be nice to be able to pass in a function like
function log(filesCount, target) { console.log(`${customPrefix()} ${filesCount} injected at ${target.path}`);
so I can keep my output consistent without sacrificing useful runtime info.
Figured I'd add in how to go about implementing since it's a pretty small change.
// ...
function getNewContent(target, collection, opt) {
/* Assign from opt or default to the old functionality */
var logger = opt.log || (opt.quiet ? noop : function (filesCount) {
if (filesCount) {
log(cyan(filesCount) + ' files into ' + magenta(target.relative) + '.');
} else {
log('Nothing to inject into ' + magenta(target.relative) + '.');
}
});
// ...