grunt icon indicating copy to clipboard operation
grunt copied to clipboard

`grunt.file.expand` performance on Windows

Open abhijeetkpawar opened this issue 10 years ago • 1 comments

Code:

console.log('/************* Test *****************/', (new Date()).toISOString());

var t = grunt.file.expand([
    '**/*.js',
    '!node_modules/**',
    '!dist/**',
    '!app/jspm_packages/**',
    '!app/**/vendor/**',
    '!app/config.js'
 ]);

console.log(t.length, '/************* Test End *****************/', (new Date()).toISOString());

Output:

/************* Test *****************/ 2015-08-17T07:47:40.759Z
21 '/************* Test End *****************/' '2015-08-17T07:56:58.885Z'

The above code was executed on Windows 10 machine, and it took ~9min. But same code on Linux is executing within seconds.

Now if I remove negation patterns then it executes quickly on Windows also.

abhijeetkpawar avatar Aug 17 '15 10:08 abhijeetkpawar

Using [email protected], you can improve the performance of negations by using glob's new ignore option:

var ignoreGlobs = [
    'node_modules/**',
    'dist/**',
    'app/jspm_packages/**',
    'app/**/vendor/**',
    'app/config.js'
 ];
var t = grunt.file.expand({ignore: ignoreGlobs}, ['**/*.js']);

nwoltman avatar Feb 18 '16 18:02 nwoltman