Why my gulp task won't quit after its completion

I am wondering why my gulp task did not complete after its completion. This made Travis fail.

Here is the code.

export function awaitPort(port, max=60) {
  let socket, timeout, interval;
  let deferred = Q.defer();

  // Doing waiting

  return deferred.promise
};

import { exec }                   from 'child_process';

let testResults = [];
const API_V2_TEST_COMMAND = 'mocha test/api/v2 --recursive --compilers js:babel/register';

let testBin = (string) => {
  return `NODE_ENV=testing ./node_modules/.bin/${string}`;
};

gulp.task('test:api-v2:safe', ['test:prepare:server'], (done) => {
  awaitPort(TEST_SERVER_PORT).then(() => {
    let runner = exec(
      testBin(API_V2_TEST_COMMAND),
      (err, stdout, stderr) => {
        testResults.push({
          suite: 'API Specs\t',
          pass: testCount(stdout, /(\d+) passing/),
          fail: testCount(stderr, /(\d+) failing/),
          pend: testCount(stdout, /(\d+) pending/)
        });
        done();
      }
    );
    pipe(runner);
  });
});

And after starting the task, I see that the task is completed, but not completed.

[00:21:41] Using gulpfile /vagrant/gulpfile.js
[00:21:41] Starting 'test:prepare:mongo'...
[00:21:41] Finished 'test:prepare:mongo' after 74 ms
[00:21:41] Starting 'test:prepare:server'...
[00:21:41] Finished 'test:prepare:server' after 15 ms
[00:21:41] Starting 'test:api-v2:safe'...
[00:22:15] Finished 'test:api-v2:safe' after 34 s
+4
source share

Source: https://habr.com/ru/post/1614673/


All Articles