From 893089ab083e013e7851cf4e1ee17ede169b6015 Mon Sep 17 00:00:00 2001 From: sparshithNR Date: Thu, 13 Jun 2019 15:49:43 -0700 Subject: [PATCH 1/3] Ignore all those folders mentioned in the gitignore. 1) ignore node_modules and .git folder always 2) Added test for new function 3) added sample .gitignore file in fixtures folder testing --- src/cli/run.js | 6 ++++-- src/cli/utils.js | 13 ++++++++++++- test/cli/fixtures/.gitignore | 2 ++ test/cli/utils.js | 8 ++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 test/cli/fixtures/.gitignore create mode 100644 test/cli/utils.js diff --git a/src/cli/run.js b/src/cli/run.js index fcda91da9..4347a0bf2 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" +].concat( utils.getIgnoreList( process.cwd() ) ); + const RESTART_DEBOUNCE_LENGTH = 200; let QUnit; diff --git a/src/cli/utils.js b/src/cli/utils.js index 2f47fb883..d6522bf24 100644 --- a/src/cli/utils.js +++ b/src/cli/utils.js @@ -12,6 +12,16 @@ function existsStat() { } } + +function getIgnoreList( baseDir ) { + const gitFilePath = path.join( baseDir, ".gitignore" ); + if ( fs.existsSync( gitFilePath ) ) { + const gitIgnore = fs.readFileSync( gitFilePath, "utf-8" ); + return gitIgnore.trim().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/fixtures/.gitignore b/test/cli/fixtures/.gitignore new file mode 100644 index 000000000..c7a6ef61c --- /dev/null +++ b/test/cli/fixtures/.gitignore @@ -0,0 +1,2 @@ +/abcd +/efgh \ No newline at end of file diff --git a/test/cli/utils.js b/test/cli/utils.js new file mode 100644 index 000000000..ee59e843a --- /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( "test/cli/fixtures" ); + assert.deepEqual( ignoreList, [ "/abcd", "/efgh" ] ); + } ); +} ); From a35d33a15fa76d4ef6dea7339a85da4772cb4027 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Fri, 14 Jun 2019 01:00:38 +0100 Subject: [PATCH 2/3] !fixup Add new line at EOF --- test/cli/fixtures/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cli/fixtures/.gitignore b/test/cli/fixtures/.gitignore index c7a6ef61c..787f73d47 100644 --- a/test/cli/fixtures/.gitignore +++ b/test/cli/fixtures/.gitignore @@ -1,2 +1,2 @@ /abcd -/efgh \ No newline at end of file +/efgh From 69533521d88106d83b313368f98a0a7eeb8d7eae Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Fri, 14 Jun 2019 01:01:00 +0100 Subject: [PATCH 3/3] !fixup rename test --- test/cli/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cli/utils.js b/test/cli/utils.js index ee59e843a..6bc8e9691 100644 --- a/test/cli/utils.js +++ b/test/cli/utils.js @@ -1,7 +1,7 @@ const { getIgnoreList } = require( "../../src/cli/utils" ); QUnit.module( "getIgnoreList", function() { - QUnit.test( "reads getIgnoreList", function( assert ) { + QUnit.test( "reads .gitignore", function( assert ) { const ignoreList = getIgnoreList( "test/cli/fixtures" ); assert.deepEqual( ignoreList, [ "/abcd", "/efgh" ] ); } );