I have a file, testboot.js
, that I want to inject import statements like so:
import "../app/app.spec";
import "../app/navbar/navbar.spec";
Note that the import statement is relative to testboot.js
. I am having trouble figuring out a clean way of doing this using gulp. Here is my partial gulp task:
gulp.task("inject", function (cb) {
gulp
.src("src/client/app/**/*.spec.js")
.pipe(debug())
.pipe(filenames("inject"))
.on("end", function () {
filenames.get("inject").map(function(e){
// do something
});
util.log("in end"); // never called
cb();
});
});
But the "end" handler is never called. Can anyone help me out with this problem? Thank you.
You're listening for the wrong event. From the Node.js documentation on
Stream
:That means you either have to listen for the
'finish'
event:Or you have to ensure that the callback in
stream._flush()
is invoked, e.g. withgulp.dest()
: