Closed Alexandrescu closed 9 years ago
Not sure if you got notified, but there’s some discussion about this issue here: https://github.com/gimm/gulp-express/issues/3.
I have looked over #3 and it works. In the example given on the readme page, server.run in this line:
gulp.watch(['app.js', 'routes/**/*.js'], [server.run]);
is (you might think) running with the default options. This is wrong! Either enforce using the plugin such as in issue 3 or not. This is because it's evaluating server.run as a string - this is the type watch is expecting to find. I reckon because it can't match any of the tasks (or maybe because it's matching all of them) it's going to run all the tasks when the watch is triggered.
Doing this:
gulp.watch(['app.js', 'routes/**/*.js'], server.run(serverOptions));
Evaluates the function once and it's going to have the return value of it 'called' by watch.
This is briefly the reason why #3 works and what you have written doesn't.
In my opinion (since I'm a lazy person), I would mention this on the main page. It would save people valuable time.
This is why javascript should be typed. Have a good day!
@Alexandrescu I’m sorry but I don’t understand what you’re saying. Have your resolved your issue? If yes, what changes did you perform to your gulpfile?
Also, you wrote:
This is briefly the reason why #3 works and what you have written doesn't.
What are you referring to? I didn’t post any code. I just posted a screenshot.
Gah - this should have be a 0.2 change; just spent a day bashing my head against the wall because server.run changed the signature. Sigh.
+1, that's a big thing to change. glad @mlaccetti was able to find it.
@mlaccetti really sorry for not making it clear :(
This is the output that happens when the server is notify to restart (server.run). (when app.js is modified)
(Part of) My gulp file is:
I don't really understand what happens when server.run is called. Seems like it's calling node start - which in my case is set to be "gulp", meaning it should call only the default task, but what happens is it seems to be calling all the tasks in my gulp file. Where is my reasoning wrong?