Skip to content

Commit

Permalink
feat: bump default depth to 4 for --all-projects
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Jul 1, 2020
1 parent f738d4c commit 79dbca8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion help/help.txt
Expand Up @@ -33,7 +33,7 @@ Options:
--detection-depth=<number>
(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=<comma separated list of directory names>
(test & monitor commands only)
Can be used with --all-projects and --yarn-workspaces to indicate sub-directories to exclude.
Expand Down
4 changes: 2 additions & 2 deletions src/lib/find-files.ts
Expand Up @@ -51,7 +51,7 @@ export async function find(
path: string,
ignore: string[] = [],
filter: string[] = [],
levelsDeep = 2,
levelsDeep = 4,
): Promise<string[]> {
const found: string[] = [];
// ensure we ignore find against node_modules path.
Expand Down Expand Up @@ -100,7 +100,7 @@ async function findInDirectory(
path: string,
ignore: string[] = [],
filter: string[] = [],
levelsDeep = 2,
levelsDeep = 4,
): Promise<string[]> {
const files = await readDirectory(path);
const toFind = files
Expand Down
16 changes: 8 additions & 8 deletions test/find-files.test.ts
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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'),
Expand Down

0 comments on commit 79dbca8

Please sign in to comment.