-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular/cli): temporarily handle boolean options in schema prefi…
…xed with `no` With this commit we introduce an interim solution for options prefixed with `no` in `schema.json` Previously, such options were handled as normal boolean option, but yargs handles options prefixed with `no` as negatations of the original option. Example with yargs, an option `noWatch` is will registered as `watch`. Closes #23397 (cherry picked from commit ba3f671)
- Loading branch information
1 parent
3dc7427
commit 5521648
Showing
6 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
tests/legacy-cli/e2e/assets/schematic-boolean-option-negated/collection.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"schematics": { | ||
"test": { | ||
"factory": "./index.js", | ||
"schema": "./schema.json", | ||
"description": "test schematic that logs the options in the console." | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
tests/legacy-cli/e2e/assets/schematic-boolean-option-negated/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exports.default = (options) => console.log(options); |
5 changes: 5 additions & 0 deletions
5
tests/legacy-cli/e2e/assets/schematic-boolean-option-negated/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "schematic-boolean-option", | ||
"version": "0.0.1", | ||
"schematics": "./collection.json" | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/legacy-cli/e2e/assets/schematic-boolean-option-negated/schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema", | ||
"type": "object", | ||
"description": "test schematic that logs the options in the console.", | ||
"properties": { | ||
"noWatch": { | ||
"type": "boolean" | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/legacy-cli/e2e/tests/misc/negated-boolean-options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { copyAssets } from '../../utils/assets'; | ||
import { execAndWaitForOutputToMatch } from '../../utils/process'; | ||
|
||
export default async function () { | ||
await copyAssets('schematic-boolean-option-negated', 'schematic-boolean-option-negated'); | ||
|
||
await execAndWaitForOutputToMatch( | ||
'ng', | ||
['generate', './schematic-boolean-option-negated:test', '--no-watch'], | ||
/noWatch: true/, | ||
); | ||
|
||
await execAndWaitForOutputToMatch( | ||
'ng', | ||
['generate', './schematic-boolean-option-negated:test', '--watch'], | ||
/noWatch: false/, | ||
); | ||
|
||
await execAndWaitForOutputToMatch( | ||
'ng', | ||
['generate', './schematic-boolean-option-negated:test'], | ||
/'noWatch' option has been declared with a 'no' prefix in the schema/, | ||
); | ||
} |