Skip to content

Commit

Permalink
fix(cli): fix could not find any [routes] variable (#1832)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Sep 18, 2024
1 parent c581b94 commit 380f7ab
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions schematics/utils/alain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import {
} from '@angular-devkit/schematics';
import { Schema as ComponentSchema } from '@schematics/angular/component/schema';
import {
findNode,
insertImport,
addProviderToModule as _addProviderToModule
addProviderToModule as _addProviderToModule,
getSourceNodes
} from '@schematics/angular/utility/ast-utils';
import { InsertChange } from '@schematics/angular/utility/change';
import { buildRelativePath, findModuleFromOptions, ModuleOptions } from '@schematics/angular/utility/find-module';
Expand All @@ -32,8 +32,6 @@ import { addServiceToModuleOrStandalone, findRoutesPath, getSourceFile, ROUTINS_
import { isStandalone } from './standalone';
import { getProject, NgAlainProjectDefinition } from './workspace';

const TEMPLATE_FILENAME_RE = /\.template$/;

export interface CommonSchema extends ComponentSchema {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
Expand Down Expand Up @@ -178,7 +176,9 @@ export function addValueToVariable(
needWrap: boolean = true
): void {
const source = getSourceFile(tree, filePath);
const node = findNode(source, ts.SyntaxKind.Identifier, variableName);
const node = getSourceNodes(source).find(
node => node.kind == ts.SyntaxKind.Identifier && node.getText() === variableName
);
if (!node) {
throw new SchematicsException(`Could not find any [${variableName}] variable in path '${filePath}'.`);
}
Expand Down

0 comments on commit 380f7ab

Please sign in to comment.