-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(js): warn users when additionalEntryPoints do not match any files (
- Loading branch information
Showing
5 changed files
with
47 additions
and
30 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { sync as globSync } from 'fast-glob'; | ||
import { logger } from '@nx/devkit'; | ||
|
||
export function createEntryPoints( | ||
additionalEntryPoints: undefined | string[], | ||
root: string | ||
): string[] { | ||
if (!additionalEntryPoints?.length) return []; | ||
const files = []; | ||
// NOTE: calling globSync for each pattern is slower than calling it all at once. | ||
// We're doing it this way in order to show a warning for unmatched patterns. | ||
// If a pattern is unmatched, it is very likely a mistake by the user. | ||
// Performance impact should be negligible since there shouldn't be that many entry points. | ||
// Benchmarks show only 1-3% difference in execution time. | ||
for (const pattern of additionalEntryPoints) { | ||
const matched = globSync([pattern], { cwd: root }); | ||
if (!matched.length) | ||
logger.warn(`The pattern ${pattern} did not match any files.`); | ||
files.push(...matched); | ||
} | ||
return files; | ||
} |
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