Skip to content

Commit 0a2da67

Browse files
committed
refactor(SampleAssetGenerator): extract _shouldConfigureRouting method
1 parent f816a6c commit 0a2da67

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/generators/SampleAssetsGenerator.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ export class SampleAssetsGenerator {
317317
}
318318
});
319319
}
320-
if (appConfig.routesConfig?.router && appConfig.routesConfig?.routesImportPath) {
320+
if (this._shouldConfigureRouting(config)) {
321321
importMap.set('@angular/router', ['provideRouter', 'withComponentInputBinding']);
322322
importMap.set(`${appConfig.routesConfig.routesImportPath}`, ['routes']);
323323
}
@@ -355,7 +355,7 @@ export class SampleAssetsGenerator {
355355
formatted += ` ${provider}${i < providers.length - 1 ? ',\n' : ''}`;
356356
});
357357
}
358-
if (config.appConfig.routesConfig?.router && config.appConfig.routesConfig?.routesImportPath) {
358+
if (this._shouldConfigureRouting(config)) {
359359
if (formatted.length > 0) {
360360
formatted += ',\n';
361361
}
@@ -364,6 +364,11 @@ export class SampleAssetsGenerator {
364364
return formatted;
365365
}
366366

367+
private _shouldConfigureRouting(config: Config): boolean {
368+
const routesConfig = config?.appConfig?.routesConfig;
369+
return !!(routesConfig?.router && routesConfig?.routesImportPath);
370+
}
371+
367372
private _getAppModuleConfig(config: Config, configImports, configAdditionalImports?) {
368373
let defaultNgDeclarations = ["AppComponent"];
369374
let defaultNgImports = ["BrowserModule", "BrowserAnimationsModule", "FormsModule"];

0 commit comments

Comments
 (0)