Skip to content

Commit

Permalink
fix(core): replace glob with fast-glob to speed up dep-graph calculat…
Browse files Browse the repository at this point in the history
…ion (#414)

Closes #410
  • Loading branch information
johannesf95 authored Apr 14, 2022
1 parent 887cf1b commit 5db4ca9
Show file tree
Hide file tree
Showing 3 changed files with 536 additions and 504 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"chokidar": "^3.5.2",
"clsx": "^1.1.1",
"eslint": "8.9.0",
"glob": "^7.2.0",
"fast-glob": "3.2.7",
"inquirer": "^8.2.0",
"prism-react-renderer": "^1.2.1",
"react": "^17.0.2",
Expand Down
16 changes: 7 additions & 9 deletions packages/utils/src/lib/utility-functions/glob.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import * as _glob from 'glob';
import * as fg from 'fast-glob';
import { workspaceRoot } from 'nx/src/utils/app-root';
import { join } from 'path';

const globOptions = {
cwd: workspaceRoot,
ignore: ['**/bin/**', '**/obj/**'],
};

/**
* Wraps the glob package in a promise api.
* Wraps the fast-glob package.
* @returns array of file paths
*/
export function glob(path: string, cwd?: string): Promise<string[]> {
return new Promise((resolve, reject) =>
_glob(
path,
!cwd ? globOptions : { cwd: join(workspaceRoot, cwd) },
(err, matches) => (err ? reject() : resolve(matches)),
),
return fg(
path,
!cwd ? globOptions : { ...globOptions, cwd: join(workspaceRoot, cwd) },
);
}

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

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

0 comments on commit 5db4ca9

Please sign in to comment.