Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue#44 more Nest like error #46

Merged
merged 2 commits into from
Oct 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/core/importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface AutoClasses {
}

export class Importer {
private classMap = new Map<string, ClassType>();
private rootPath = '';

static load(patterns: string[]): AutoClasses {
Expand Down Expand Up @@ -90,10 +91,13 @@ export class Importer {
*/
private catchOverlappedScanScope(value: { new (...args: any[]): any; name: string }, pathName: string) {
locate(value as any).then(({ path }: { path: string }) => {
this.classMap.set(path, value);
if (!this.rootPath) this.rootPath = pathName;
if (this.rootPath !== path) {
new Logger('ExceptionHandler').error(
`ComponentScan() module scope cannot be overlapped.\n\nPotential causes:\n- An overlapped dependency between modules.\n- Please check the module in '${this.rootPath}' and '${path}'\n\nScope [${value.name}]`,
`ComponentScan() module scope cannot be overlapped.\n\nPotential causes:\n- An overlapped dependency between modules.\n- Please check the module in '${
this.rootPath
}' and '${path}'\n\nScope [${value.name} -> ${this.classMap.get(this.rootPath)!.name}]`,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know some people may dislike ! syntax. But in this case, this.rootPath key is definetely defined, so I used it to make the code short and clear.
Looks fine to me, but if you have a different opinion please let me know. 😄

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

);
process.exit(1);
}
Expand Down