Skip to content

Commit b1f210c

Browse files
committed
fix(@angular-devkit/schematics-cli): Add boolean type inference for 'true' and 'false' string values in argument parsing
Handles booleans correctly Closes angular#32361
1 parent 1f1b21d commit b1f210c

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

packages/angular_devkit/architect/bin/architect.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,16 @@ function parseOptions(args: string[]): Options {
180180
}
181181
}
182182

183-
// Type inference for numbers
184-
if (typeof value === 'string' && !isNaN(Number(value))) {
185-
value = Number(value);
183+
if (typeof value === 'string') {
184+
if (!isNaN(Number(value))) {
185+
// Type inference for numbers
186+
value = Number(value);
187+
} else if (value === 'true') {
188+
// Type inference for booleans
189+
value = true;
190+
} else if (value === 'false') {
191+
value = false;
192+
}
186193
}
187194

188195
const camelName = strings.camelize(name);

packages/angular_devkit/schematics_cli/bin/schematics.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,16 @@ function parseOptions(args: string[]): Options {
520520
}
521521
}
522522

523-
// Type inference for numbers
524-
if (typeof value === 'string' && !isNaN(Number(value))) {
525-
value = Number(value);
523+
if (typeof value === 'string') {
524+
if (!isNaN(Number(value))) {
525+
// Type inference for numbers
526+
value = Number(value);
527+
} else if (value === 'true') {
528+
// Type inference for booleans
529+
value = true;
530+
} else if (value === 'false') {
531+
value = false;
532+
}
526533
}
527534

528535
const camelName = strings.camelize(name);

0 commit comments

Comments
 (0)