Skip to content

Commit fe119a7

Browse files
MeAkibdgp1130
authored andcommitted
fix(@schematics/angular): show routing module suffixes in findModule error
When only routing modules are found, the error message printed the optional `routingModuleExt` parameter, which no schematic passes, so users saw "Modules with suffix 'undefined' are strictly reserved for routing.". Since 0b7d48c the lookup checks both `-routing-module.ts` and `-routing.module.ts`, so list the suffixes that are actually used. (cherry picked from commit 490a6fe)
1 parent e89807e commit fe119a7

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎packages/schematics/angular/utility/find-module.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export function findModule(
117117

118118
const errorMsg = foundRoutingModule
119119
? 'Could not find a non Routing NgModule.' +
120-
`\nModules with suffix '${routingModuleExt}' are strictly reserved for routing.` +
120+
`\nModules with suffix '${routingModuleExtensions.join("' or '")}' are strictly reserved for routing.` +
121121
`\nUse the '--skip-import' option to skip importing in NgModule.`
122122
: `Could not find an NgModule. Use the '--skip-import' option to skip importing in NgModule.`;
123123

‎packages/schematics/angular/utility/find-module_spec.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ describe('find-module', () => {
5656
expect(() => findModule(host, 'foo/src/app/anything-routing')).toThrowError(
5757
/Could not find a non Routing NgModule/,
5858
);
59+
expect(() => findModule(host, 'foo/src/app/anything-routing')).toThrowError(
60+
/Modules with suffix '-routing-module\.ts' or '-routing\.module\.ts' are strictly reserved/,
61+
);
5962
});
6063

6164
it('should throw if two modules found', () => {

0 commit comments

Comments
 (0)