Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@joepie91
Last active August 30, 2015 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joepie91/e7d66ffdb17d1ea69c56 to your computer and use it in GitHub Desktop.
Save joepie91/e7d66ffdb17d1ea69c56 to your computer and use it in GitHub Desktop.
Named logging in Gulp
function namedLog(name) {
return function gutilLog(log) {
gc = gutil.colors;
items = ["[- " + gc.magenta(name) + " -]"];
for(i in arguments) {
items.push(arguments[i]);
}
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(plumber())
.pipe(cache(taskName))
.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.
.pipe(remember(taskName))
.pipe(gulp.dest(subTask.destination));
// [...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment