question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gulp 4 seems to not finish task in gulp.series

See original GitHub issue

Hey,

first let me say that I really love what you are doing with gulp and also gulp 4. While I sadly don’t know enough about low level js to help with the release, I figured I switch a project over to gulp 4 to at least do some testing. However I ran into a problem, I am not sure if this is something with gulp or an issue on my side (probably). I did not find any solution to this issue in any other ticket, so maybe you can help me.

This is my code:

gulp.task('build-js', function (done) {

  Object.keys(filesJS).forEach(function (key) {

    gulp.src(filesJS[key])
        .pipe(sourcemaps.init())
        .pipe(babel({
          presets: [ [ 'es2015', { modules: false } ] ],
          plugins: ['transform-custom-element-classes']
        }))
        .on('error', swallowError)
        .pipe(concat(key + '.js'))

        .pipe(uglify())
        .pipe(sourcemaps.write('/'))
        .pipe(gulp.dest('public/js'))
        .on('end', function () {
          reportSavings(sizes, 'JS (' + key + '):')
        })
    })
    done()
})

gulp.task('js', gulp.series(
    'clean-js',
    function moveJsFiles () {
      return gulp.src(moveFilesJS).pipe(gulp.dest('public/js'))
    },
    'build-js',
    'rev-js',
      // do more stuff
      done();
    }
  )
)

The error I get is the following:

Error: File not found with singular glob: /Users/lukasoppermann/Code/veare/public/js/common.js

common.js is created within build-js.

When I run the tasks separately via the cli it works fine. It also works fine if I move build-js above the moveJsFiles function in the series.

I do not understand what I am doing wrong and why it only works this way. Please let me know how I can fix this.

Thank you.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ViieeScommented, Mar 15, 2018

@lukasoppermann you can also do it using underscore’s _.after:

const appJs = (cb) => {
const done = _.after(_.size(bundles), cb);

_.each(config.bundles, (paths, bundle) => {

    gulp.src(paths.css)
        // ... pipes ...
       .pipe(gulp.dest(destPath))
       .on('end', done);
});

};

0reactions
lukasoppermanncommented, Apr 26, 2017

Hey @phated I did indeed, my solution did not answer the stackOverflow question at all, and I think the answer is, that you will always have the wrapper function show up. So I see no sense in answering it with an answer that does not actually answer it. 😉

I solved it by keeping the Object.keys(filesJS).forEach(function (key) { but merging the streams to a variable define outside the forEach, which I can than return. Basically what you suggested above. So thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gulp 4 - Tasks not finished - Gulpfile.js Browsersync
The second task in your serve series doesn't return anything, gulp doesn't understand that. A task can return a stream or a promise...
Read more >
Async Completion
When composing tasks with parallel() , an error will end the composition but the other parallel tasks may or may not complete.
Read more >
How to Migrate to Gulp.js 4.0
Gulp.js 4.0 throws a warning because it needs to know when a task has completed in order to manage series() and parallel() sequences:...
Read more >
How to fix: Gulp - tasks did not complete ... you forget to signal ...
It saying that running of the Gulp task called “mynewtask” is failed, and this is because tasks did not complete: mynewtask and you...
Read more >
A quick guide for switching to gulp 4 | by Jhey Tompkins
For those in camp TL;DR — not a huge impact. Your tasks will break if they use the list parameter to define task...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found