Created
November 23, 2015 18:48
-
-
Save ipiyer/7a042d723ec14817aaf9 to your computer and use it in GitHub Desktop.
gulp plugin returning promise
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
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