0

I have several gulp subtasks which will keep monitoring files to update. I need them launched up in sequence.

gulp.task('production', ['update-build-info/production:live', 'build-resources/production:live', 'npm-start', 'simulator'], () => {
  console.log('finished!!!');
});

My questions are:

  1. I use gulp-watch to track files for live update. This will lead to sequential launching failed, because those subtasks will simply return before it completes launching and becomes idle.

How can I arrange those subtask like this:

[start main task]-->[1. update-build-info]
                          |
                    start watching files
                          |
                    update matched files
                          |
                    idle (keep watching)-->[2. build-resources]
                          |                     |
                    update new changes     start watching files
                                                |
                                           update matched files
                                                |
                                           idle (keep watching)-->[3. run npm start]
                                                |                     |                                                            
                                           update new changes     finish launching, idle --> [4. build and launch iOS app]
                                                                      |
                                                                  update new changes
  1. Executing shell script npm start will cause the subtask never ends, and lead to the callback will never be called (print finished!!!). If I remove this subtask, the callback will be called again. How can I make the subtask send a completed signal to trigger the callback?

The npm start is babel-node node_modules/react-native/local-cli/cli.js start.


EDIT:

I've demonstrated why this topic "How to run Gulp tasks sequentially one after the other" doesn't work for me. I use gulp-watch which will cause async tasks, and I have no idea how to sync them when it initial work is done .

Another watching mechanism using node.js is npm start which will block the task and never end.

I think I need to use RxJS to do the job if there is no way to resolve this problem.

Community
  • 1
  • 1
Xaree Lee
  • 3,188
  • 3
  • 34
  • 55
  • Possible duplicate of [How to run Gulp tasks sequentially one after the other](http://stackoverflow.com/questions/22824546/how-to-run-gulp-tasks-sequentially-one-after-the-other) – Sven Schoenung Sep 26 '16 at 07:19
  • gulp watch can trigger another task that is set up sequentially using gulp-sequence or run-sequence - it's not clear to me why that does not work for you. you might consider explaining further – danyamachine Sep 27 '16 at 01:35

0 Answers0