diff --git a/src/cli/run.js b/src/cli/run.js index fcda91da9..4d4e98c4d 100644 --- a/src/cli/run.js +++ b/src/cli/run.js @@ -7,8 +7,10 @@ const requireQUnit = require( "./require-qunit" ); const utils = require( "./utils" ); const IGNORED_GLOBS = [ - "**/node_modules/**" + ".git", + "node_modules" ]; + const RESTART_DEBOUNCE_LENGTH = 200; let QUnit; @@ -18,6 +20,11 @@ function run( args, options ) { // Default to non-zero exit code to avoid false positives process.exitCode = 1; + // Do not push content of .gitignore everytime when run is called + if ( IGNORED_GLOBS.length === 2 ) { + IGNORED_GLOBS.push.apply( IGNORED_GLOBS, utils.getIgnoreList( process.cwd() ) ); + } + const files = utils.getFilesFromArgs( args ); QUnit = requireQUnit(); diff --git a/src/cli/utils.js b/src/cli/utils.js index 2f47fb883..0c670687e 100644 --- a/src/cli/utils.js +++ b/src/cli/utils.js @@ -12,6 +12,16 @@ function existsStat() { } } + +function getIgnoreList( baseDir ) { + if ( fs.existsSync( `${baseDir}/.gitignore` ) ) { + let gitIgnore = fs.readFileSync( `${baseDir}/.gitignore`, "utf-8" ); + gitIgnore = gitIgnore.trim(); + return gitIgnore.split( "\n" ); + } + return []; +} + function findFilesInternal( dir, options, result = [], prefix = "" ) { fs.readdirSync( dir ).forEach( ( name ) => { const fullName = path.join( dir, name ); @@ -85,5 +95,6 @@ module.exports = { findFiles, capitalize, error, - getFilesFromArgs + getFilesFromArgs, + getIgnoreList }; diff --git a/test/cli/utils.js b/test/cli/utils.js new file mode 100644 index 000000000..15c4a9687 --- /dev/null +++ b/test/cli/utils.js @@ -0,0 +1,8 @@ +const { getIgnoreList } = require( "../../src/cli/utils" ); + +QUnit.module( "getIgnoreList", function() { + QUnit.test( "reads getIgnoreList", function( assert ) { + const ignoreList = getIgnoreList( `${process.cwd()}` ); + assert.deepEqual( ignoreList, [ "dist", "node_modules", "build/report", "browserstack-run.pid", "temp/", "docs/_site/" ] ); + } ); +} );