Skip to content

Instantly share code, notes, and snippets.

Last active August 30, 2015 17:45
What would you like to do?
Named logging in Gulp
function namedLog(name) {
return function gutilLog(log) {
gc = gutil.colors;
items = ["[- " + gc.magenta(name) + " -]"];
for(i in arguments) {
gutil.log.apply(null, items);

The Buffer output comes from namedLog, and makes it easier to determine whether a change was picked and compiled up correctly.

// [...]
var spy = require("through2-spy");
// [...]
return gulp.src(subTask.source, {base: subTask.base})
.pipe(processor.on('error', gutil.log)) // `processor` refers to eg. gulp-jade or whatever
.pipe(spy.obj(namedLog(taskName))) // this does the actual logging, using namedLog defined above.
// [...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment