OverZealous / run-sequence

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

fact of life? external process stops sequence #84

Closed rkoberg closed 7 years ago

rkoberg commented 7 years ago

I have a task that calls an external process, then the gulp sequence stops. Is this a bug or just a fact of life? For example, this will stop the sequence:

...
import run from 'gulp-run';
...
gulp.task('well-form-2-12', done => {
  const xslSource = path.join('xsl', 'well-former-2-12.xsl');

  run(`java ${SAXON} -o:${ignoreFilePath} -s:${LOCAL_XML} -xsl:${xslSource} -x:${TAGSOUP}`).exec()
    .on('error', err => done(err))
    .on('finish', () => {
      del(ignoreFilePath);
      // done();
    });
});

Also happens with calls to apache-ant (e.g. ant some-build-task)

OverZealous commented 7 years ago

I don't know what you are asking here.

run-sequence just runs gulp tasks. Does the task run on it's own? Is there an error?

In your example above, you aren't ever calling the callback (// done()), which means the sequence won't ever continue. If your tasks never complete, then the sequence never continues.

rkoberg commented 7 years ago

I tried with done() uncommented as well. gulp-run executes a command line java program. There is no error. I was assuming that the java process short circuits the gulp process and just ends it.

OverZealous commented 7 years ago

run-sequence only runs gulp tasks. If the program exits due to the task, then there's nothing here related to this library.

As long as gulp-run is forking the Java process, it's unlikely that it's killing the task. After quickly looking at the gulp-run library, it looks like you are using it incorrectly. It's clearly designed to be returned directly as a stream, no need to use a callback at all. You should be able to just do something like:

 return run(`…your command…`).exec()
    .pipe(/* …delete the file… */);
rkoberg commented 7 years ago

OK, sorry for being dense (I originally was returning the stream). I was looking in the wrong place and was mistakenly focusing on the external process. It was another task running in parallel where I needed to use event-stream.merge where I was writing out multiple files. Closing...