forked from nrwl/nx
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "feat(core): support nested ignore files (nrwl#10455)"
This reverts commit 36d8ee2.
- Loading branch information
1 parent
7b1164f
commit 8a664c4
Showing
18 changed files
with
245 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 22 additions & 17 deletions
39
packages/angular/src/generators/stories/lib/tree-utilities.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,36 @@ | ||
import type { Tree } from '@nrwl/devkit'; | ||
import { joinPathFragments } from '@nrwl/devkit'; | ||
import { createGitIgnoreFromTree } from 'nx/src/utils/ignore'; | ||
import type { Ignore } from 'ignore'; | ||
import ignore from 'ignore'; | ||
|
||
export function getAllFilesRecursivelyFromDir( | ||
tree: Tree, | ||
dir: string | ||
): string[] { | ||
const ignore = createGitIgnoreFromTree(tree); | ||
if (isPathIgnored(tree, dir)) { | ||
return []; | ||
} | ||
|
||
function inner(dir: string) { | ||
if (ignore.ignores(dir)) { | ||
return []; | ||
const files: string[] = []; | ||
const children = tree.children(dir); | ||
children.forEach((child) => { | ||
const childPath = joinPathFragments(dir, child); | ||
if (tree.isFile(childPath)) { | ||
files.push(childPath); | ||
} else { | ||
files.push(...getAllFilesRecursivelyFromDir(tree, childPath)); | ||
} | ||
}); | ||
|
||
const files: string[] = []; | ||
const children = tree.children(dir); | ||
children.forEach((child) => { | ||
const childPath = joinPathFragments(dir, child); | ||
if (tree.isFile(childPath)) { | ||
files.push(childPath); | ||
} else { | ||
files.push(...inner(childPath)); | ||
} | ||
}); | ||
return files; | ||
} | ||
|
||
return files; | ||
function isPathIgnored(tree: Tree, path: string): boolean { | ||
let ig: Ignore; | ||
if (tree.exists('.gitignore')) { | ||
ig = ignore(); | ||
ig.add(tree.read('.gitignore', 'utf-8')); | ||
} | ||
|
||
return inner(dir); | ||
return path !== '' && ig?.ignores(path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.