I have a function I use in my gulp setup that looks something like:
// browserified - the result of browserify(...) x = function(browserified, entryScriptPath){ // Promise is bluebird return new Promise(function(resolve, reject){ var basename = path.basename(entryScriptPath, path.extname(entryScriptPath)) + '.js'; browserified.bundle() .pipe(source(basename)) // vinyl-source-stream .pipe(buffer()) // vinyl-buffer .pipe(aGulpPlugin()) .pipe(anotherGulpPlugin()) //... .on('error', reject) .on('finish', resolve); }); }
An error was occurring while bundling but I got no textual error or stackerror, it just exited eventually with the wrong code. So I found this:
Return a readable stream with the javascript file contents or optionally specify a cb(err, buf) to get the buffered results.
I passed a callback like browserified.bundle(function(err){ if(err) reject(err); })
which worked fine when there was an error but that now breaks everything else when there isn't an error because the docs say you can either get a stream or a buffer but not both.
Is there a way I can grab this error another way and still keep my code? Or if not, I know I could move a lot of my stream stuff inside that callback but sorry I'm no stream expert and am unsure how to get that buffer into a vinyl transform stream which suits the gulp plugins. Like:
browserified.bundle(function(err, buf){ if(err) return reject(err); // ???? // something with buf // ???? .pipe(aGulpPlugin()) .pipe(anotherGulpPlugin()) // ... });
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4