Skip to content

Commit 8c7c7ac

Browse files
committed
fix(@angular/cli): correctly parse and resolve relative schematic collection names on Windows
Previously, the logic incorrectly extracted the drive letter as the collection name when the schematic collection was specified as relative on Windows. This fix ensures that relative paths are parsed and resolved correctly, preventing the drive letter from being mistakenly treated as the collection name. Closes #29559
1 parent 751a598 commit 8c7c7ac

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

packages/angular/cli/src/command-builder/schematics-command-module.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
FileSystemSchematicDescription,
1414
NodeWorkflow,
1515
} from '@angular-devkit/schematics/tools';
16-
import { relative, resolve } from 'path';
16+
import { relative } from 'path';
1717
import { Argv } from 'yargs';
1818
import { isPackageNameSafeForAnalytics } from '../analytics/analytics';
1919
import { EventCustomDimension } from '../analytics/analytics-parameters';
@@ -277,12 +277,6 @@ export abstract class SchematicsCommandModule
277277

278278
@memoize
279279
protected async getSchematicCollections(): Promise<Set<string>> {
280-
// Resolve relative collections from the location of `angular.json`
281-
const resolveRelativeCollection = (collectionName: string) =>
282-
collectionName.charAt(0) === '.'
283-
? resolve(this.context.root, collectionName)
284-
: collectionName;
285-
286280
const getSchematicCollections = (
287281
configSection: Record<string, unknown> | undefined,
288282
): Set<string> | undefined => {
@@ -292,7 +286,7 @@ export abstract class SchematicsCommandModule
292286

293287
const { schematicCollections } = configSection;
294288
if (Array.isArray(schematicCollections)) {
295-
return new Set(schematicCollections.map((c) => resolveRelativeCollection(c)));
289+
return new Set(schematicCollections);
296290
}
297291

298292
return undefined;
@@ -399,6 +393,10 @@ export abstract class SchematicsCommandModule
399393

400394
private getResolvePaths(collectionName: string): string[] {
401395
const { workspace, root } = this.context;
396+
if (collectionName[0] === '.') {
397+
// Resolve relative collections from the location of `angular.json`
398+
return [root];
399+
}
402400

403401
return workspace
404402
? // Workspace

0 commit comments

Comments
 (0)