OverZealous / run-sequence

Run a series of dependent gulp tasks in order
MIT License
961 stars 56 forks source link

Synchronous task not completing #66

Closed Doormouse2House closed 8 years ago

Doormouse2House commented 8 years ago

I'm not suggesting this is a problem with run-sequence, but if anyone has any thoughts on my question raised on SO, that would be appreciated!

OverZealous commented 8 years ago

I don't know how you expect someone to parse through all that, but if your task accepts an argument, Gulp assumes it's asynchronous. You must call the done function passed in to complete the task, or it will hang indefinitely.

All tasks in Gulp should return a Promise or stream, or they should accept the callback and call it upon completion. You can't accept a callback and return a value—the returned value will be ignored.

OverZealous commented 8 years ago

Also, this is a gulp thing, I don't think it has anything to do with run-sequence.

Doormouse2House commented 8 years ago

It doesn't hang indefinitely, in fact gulp terminates before the 2nd task can finish, which is why I raised it here instead of in the gulp section - that may turn out to be an incorrect assumption on my part. You say that there are in essence two options, either return a Promise/stream or utilise a provided callback to let Gulp know that it is done; in this case a variation of the second option is used, stolen from other areas of the seed which work without issue. By returning a function that takes in it's own callback as an argument, you can (at least, if I'm interpretting it correctly) ensure the synchronous nature of the task by calling said callback from within the returned function itself, for example on the resolution of a promise. That being said, I can say all I want about how I've intrepetted the pattern used in the seed, but my code doesn't work so... What do I know??

Doormouse2House commented 8 years ago

One of the angular2-seed guys sorted me out - I was using a wrapper function, but not calling it, meaning my task function wasn't returned. I'll clean it up and update the SO Q.