Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long Init Time #11

Closed
jonathanrdelgado opened this issue Feb 10, 2014 · 4 comments
Closed

Long Init Time #11

jonathanrdelgado opened this issue Feb 10, 2014 · 4 comments

Comments

@jonathanrdelgado
Copy link

I have about 100 files I am watching, just javascript source files and tests.

I noticed when I init gulp-watch, it takes a good thirty seconds for it to finish adding files to watch, past that, everything is blazing fast. (Mocha etc.) I'm basing my assumption that this is abnormal due to grunt-watch loading relatively fast (~1sec) under the same conditions.

Is this normal?

@dashed
Copy link

dashed commented Feb 11, 2014

what does your gulpfile.js look like?

@jonathanrdelgado
Copy link
Author

Thanks for the reply!

var gulp = require('gulp'),
    grep = require('gulp-grep-stream'),
    jshint = require('gulp-jshint'),
    mocha = require('gulp-mocha'),
    util = require('gulp-util'),
    watch = require('gulp-watch');

gulp.task('default', function(){

    gulp.src(['lib/**', 'tests/**'], { read: false })
        .pipe(watch({ emit: 'all' }, function(files){

            files
                .pipe(jshint({ expr: true }))
                .pipe(jshint.reporter('default'))
                .pipe(grep('**/tests/**/*.js'))
                .pipe(mocha({ reporter: 'spec' }))
                .on('error', function(){
                    util.beep();
                });

        }));

});

@floatdrop
Copy link
Owner

You should try to use glob mode, instead of piping file by file into watch:

var gulp = require('gulp'),
    grep = require('gulp-grep-stream'),
    jshint = require('gulp-jshint'),
    mocha = require('gulp-mocha'),
    util = require('gulp-util'),
    watch = require('gulp-watch');

gulp.task('default', function() {
    watch({ glob: ['lib/**', 'tests/**'], emit: 'all' }, function(files){
            files
                .pipe(jshint({ expr: true }))
                .pipe(jshint.reporter('default'))
                .pipe(grep('**/tests/**/*.js'))
                .pipe(mocha({ reporter: 'spec' }))
                .on('error', function(){
                    util.beep();
                });
        });
});

@jonathanrdelgado
Copy link
Author

Fixed, thank you for that.

Hopefully this issue serves future users!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants