Skip to content

Commit 5db4ca9

Browse files
authored
fix(core): replace glob with fast-glob to speed up dep-graph calculation (#414)
Closes #410
1 parent 887cf1b commit 5db4ca9

File tree

3 files changed

+536
-504
lines changed

3 files changed

+536
-504
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"chokidar": "^3.5.2",
2727
"clsx": "^1.1.1",
2828
"eslint": "8.9.0",
29-
"glob": "^7.2.0",
29+
"fast-glob": "3.2.7",
3030
"inquirer": "^8.2.0",
3131
"prism-react-renderer": "^1.2.1",
3232
"react": "^17.0.2",

packages/utils/src/lib/utility-functions/glob.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
import * as _glob from 'glob';
1+
import * as fg from 'fast-glob';
22
import { workspaceRoot } from 'nx/src/utils/app-root';
33
import { join } from 'path';
44

55
const globOptions = {
66
cwd: workspaceRoot,
7+
ignore: ['**/bin/**', '**/obj/**'],
78
};
89

910
/**
10-
* Wraps the glob package in a promise api.
11+
* Wraps the fast-glob package.
1112
* @returns array of file paths
1213
*/
1314
export function glob(path: string, cwd?: string): Promise<string[]> {
14-
return new Promise((resolve, reject) =>
15-
_glob(
16-
path,
17-
!cwd ? globOptions : { cwd: join(workspaceRoot, cwd) },
18-
(err, matches) => (err ? reject() : resolve(matches)),
19-
),
15+
return fg(
16+
path,
17+
!cwd ? globOptions : { ...globOptions, cwd: join(workspaceRoot, cwd) },
2018
);
2119
}
2220

@@ -40,7 +38,7 @@ export function findProjectFileInPath(path: string): Promise<string> {
4038
}
4139

4240
export function findProjectFileInPathSync(path: string): string {
43-
const results = _glob.sync(`${path}/**/*.*proj`, globOptions);
41+
const results = fg.sync(`${path}/**/*.*proj`, globOptions);
4442
if (!results || results.length === 0) {
4543
throw new Error(
4644
"Unable to find a build-able project within project's source directory!",

0 commit comments

Comments
 (0)