Skip to content

Instantly share code, notes, and snippets.

@ipiyer
Created November 23, 2015 18:48
Show Gist options
  • Save ipiyer/7a042d723ec14817aaf9 to your computer and use it in GitHub Desktop.
Save ipiyer/7a042d723ec14817aaf9 to your computer and use it in GitHub Desktop.
gulp plugin returning promise
const though = require("through2"),
syncDB = require("../syncdb");
module.exports = function() {
return through.obj(function(file, enc, cb) {
console.log(file.path, enc);
if (file.isNull()) {
// return empty file
return cb(null, file);
}
syncDB(file.path)
.then(function() {
cb(null, file);
}).catch(function(e) {
cb(e, null);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment