Skip to content

Instantly share code, notes, and snippets.

@joepie91 joepie91/named-log.js

Last active Aug 30, 2015
Embed
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) {
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
You can’t perform that action at this time.