The Buffer
output comes from namedLog
, and makes it easier to determine whether a change was picked and compiled up correctly.
Last active
August 30, 2015 17:45
-
-
Save joepie91/e7d66ffdb17d1ea69c56 to your computer and use it in GitHub Desktop.
Named logging in Gulp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [...] | |
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