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 command must be run two time

See original GitHub issue

Hello,

At the first launch of the compilation, Gulp does not generate the files dependent on other generated files.

ex:

  • o = h + cpp
  • o = h + cpp
  • lib = o + o

You must run the Gulp command a second time I can not find the problem

I have this gulpfile:

var SRC_DIR = 'src'
var EXCLUDE_DOT = `!${SRC_DIR}/**/.*`
var BUILD_DIR = 'dist/.tmp'
var DIST_DIR = 'dist'

const PP_OPTS =  { NODE_ENV: 'production', DEBUG: false}

// 1) compiler les fichiers un par un sauf le tag
// 2) les placer avec le tag dans un dossier tmp
// 3) compiler le tag

gulp.task('default', [ 'mv_exclude', 'mv_tag', 'js', 'tag'])

gulp.task('mv_exclude', function()
{
    gulp.src(`${EXCLUDE_DOT}/*`,
        { base: SRC_DIR})
        .pipe(gulp.dest(BUILD_DIR))
})

gulp.task('js',  function()
{
    gulp.src([`${SRC_DIR}/**/*.js`, EXCLUDE_DOT],
        { base: SRC_DIR})
        .pipe(
            babel({ presets: ['es2015'] })
        )
        .pipe(gulp.dest(BUILD_DIR))
})

gulp.task('mv_tag', function()
{
    gulp.src([`${SRC_DIR}/**/*.tag`, EXCLUDE_DOT],
        { base: SRC_DIR})
        .pipe(gulp.dest(BUILD_DIR))
})
        
gulp.task('tag', function()
{
    gulp.src([`${BUILD_DIR}/**/*.tag`, EXCLUDE_DOT],
        { base: BUILD_DIR})
        .pipe(
            riot()
        )
        .pipe(
            concat('bundle.js')
        )
        .pipe(
            preprocess({ context: PP_OPTS, extension: 'js' } )
        )
        .pipe(
            minify({ext:{ min:'.min.js'}})
        )
        .pipe(gulp.dest(DIST_DIR))
})

At the first launch:

image

And the second time

image

And I have no error or notice. I also searched here, but nothing … Did I make a mistake orr is this a bug?

This has already happened and every time this happens when I move files to avoid file name conflis

Merci !

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
doowbcommented, Jul 18, 2017

You should be returning the stream in in your tasks. Where you have gulp.src(... change it to return gulp.src(.... This notifies gulp that the task is using a stream and to wait for it to end.

If this doesn’t help, there’s probably something else wrong in a plugin. Either way, this isn’t a gulp issue and you could find more help on Stack Overflow.

0reactions
doowbcommented, Jul 18, 2017

This is not a bug.

See the task documentation on how tasks and their dependencies are executed. You need to tell the mv_tag task a dependency of the tag task to ensure the files have finished copying.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gulp.js, watch task runs twice when saving files - Stack Overflow
Gulp.js, watch task runs twice when saving files · With that exact same code, it runs only once for me. · My guess...
Read more >
Using it with gulp-watch, runs multiple times · Issue #6 - GitHub
Every time I save a test file, it adds the files to the stack and runs that many times. The below result is...
Read more >
Quick Start | gulp.js
To run multiple tasks, you can use gulp <task> <othertask> . Result#. The default task will run and do nothing. Output: Starting default...
Read more >
Getting Started with Gulp.js - Semaphore Tutorial
Learn how to set up and use Gulp.js, a task runner for Node.js based ... It only needs to read a file once,...
Read more >
Gulp for WordPress: Initial Setup - CSS-Tricks
The reason we need to delineate between the two is that some details in our tasks will be time and memory-consuming, which only...
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