diff --git a/help/help.txt b/help/help.txt index 778cbbfb532..4bf5cda8c1c 100644 --- a/help/help.txt +++ b/help/help.txt @@ -33,7 +33,7 @@ Options: --detection-depth= (test & monitor commands only) Use with --all-projects or --yarn-workspaces to indicate how many sub-directories to search. - Defaults to 2 (the current working directory and one sub-directory). + Defaults to 4 (the current working directory and three sub-directories). --exclude= (test & monitor commands only) Can be used with --all-projects and --yarn-workspaces to indicate sub-directories to exclude. diff --git a/src/lib/find-files.ts b/src/lib/find-files.ts index 3fd24bd1949..8ae52800755 100644 --- a/src/lib/find-files.ts +++ b/src/lib/find-files.ts @@ -51,7 +51,7 @@ export async function find( path: string, ignore: string[] = [], filter: string[] = [], - levelsDeep = 2, + levelsDeep = 4, ): Promise { const found: string[] = []; // ensure we ignore find against node_modules path. @@ -100,7 +100,7 @@ async function findInDirectory( path: string, ignore: string[] = [], filter: string[] = [], - levelsDeep = 2, + levelsDeep = 4, ): Promise { const files = await readDirectory(path); const toFind = files diff --git a/test/find-files.test.ts b/test/find-files.test.ts index c2c7b5b7e28..fff035eeb1c 100644 --- a/test/find-files.test.ts +++ b/test/find-files.test.ts @@ -5,8 +5,8 @@ import { find } from '../src/lib/find-files'; const testFixture = path.join(__dirname, 'fixtures', 'find-files'); test('find all files in test fixture', async (t) => { - // four levels deep to find all - const result = await find(testFixture, [], [], 4); + // six levels deep to find all + const result = await find(testFixture, [], [], 6); const expected = [ path.join(testFixture, 'README.md'), path.join( @@ -36,8 +36,8 @@ test('find all files in test fixture', async (t) => { }); test('find all files in test fixture ignoring node_modules', async (t) => { - // four levels deep to ensure node_modules is tested - const result = await find(testFixture, ['node_modules'], [], 4); + // six levels deep to ensure node_modules is tested + const result = await find(testFixture, ['node_modules'], [], 6); const expected = [ path.join(testFixture, 'README.md'), path.join( @@ -67,16 +67,16 @@ test('find all files in test fixture ignoring node_modules', async (t) => { }); test('find package.json file in test fixture ignoring node_modules', async (t) => { - // four levels deep to ensure node_modules is tested + // six levels deep to ensure node_modules is tested const nodeModulesPath = path.join(testFixture, 'node_modules'); - const result = await find(nodeModulesPath, [], ['package.json'], 4); + const result = await find(nodeModulesPath, [], ['package.json'], 6); const expected = []; t.same(result, expected, 'should return expected file'); }); test('find package.json file in test fixture (by default ignoring node_modules)', async (t) => { - // four levels deep to ensure node_modules is tested - const result = await find(testFixture, [], ['package.json'], 4); + // six levels deep to ensure node_modules is tested + const result = await find(testFixture, [], ['package.json'], 6); const expected = [ path.join(testFixture, 'npm', 'package.json'), path.join(testFixture, 'npm-with-lockfile', 'package.json'),