|
1 | 1 | import assert from 'node:assert/strict'; |
2 | 2 | import { homedir } from 'node:os'; |
3 | | -import * as path from 'node:path'; |
| 3 | +import { join } from 'node:path'; |
4 | 4 | import { deleteFile, expectFileToExist } from '../../../utils/fs'; |
5 | 5 | import { ng } from '../../../utils/process'; |
6 | 6 | import { expectToFail } from '../../../utils/utils'; |
7 | 7 |
|
8 | 8 | export default async function () { |
9 | | - await expectToFail(() => |
10 | | - ng('config', '--global', 'schematics.@schematics/angular.component.inlineStyle'), |
11 | | - ); |
| 9 | + const globalConfigPath = join(homedir(), '.angular-config.json'); |
12 | 10 |
|
13 | | - await ng('config', '--global', 'schematics.@schematics/angular.component.inlineStyle', 'false'); |
14 | | - let output = await ng( |
15 | | - 'config', |
16 | | - '--global', |
17 | | - 'schematics.@schematics/angular.component.inlineStyle', |
18 | | - ); |
19 | | - assert.match(output.stdout, /false\n?/); |
| 11 | + try { |
| 12 | + await expectToFail(() => |
| 13 | + ng('config', '--global', 'schematics.@schematics/angular.component.inlineStyle'), |
| 14 | + ); |
20 | 15 |
|
21 | | - // This test requires schema querying capabilities |
22 | | - // .then(() => expectToFail(() => { |
23 | | - // return ng('config', '--global', 'schematics.@schematics/angular.component.inlineStyle', 'INVALID_BOOLEAN'); |
24 | | - // })) |
| 16 | + await ng('config', '--global', 'schematics.@schematics/angular.component.inlineStyle', 'false'); |
| 17 | + let output = await ng( |
| 18 | + 'config', |
| 19 | + '--global', |
| 20 | + 'schematics.@schematics/angular.component.inlineStyle', |
| 21 | + ); |
| 22 | + assert.match(output.stdout, /false\n?/); |
25 | 23 |
|
26 | | - const cwd = process.cwd(); |
27 | | - process.chdir('/'); |
28 | | - try { |
29 | | - await ng('config', '--global', 'schematics.@schematics/angular.component.inlineStyle', 'true'); |
30 | | - } finally { |
31 | | - process.chdir(cwd); |
32 | | - } |
| 24 | + const cwd = process.cwd(); |
| 25 | + process.chdir('/'); |
| 26 | + try { |
| 27 | + await ng( |
| 28 | + 'config', |
| 29 | + '--global', |
| 30 | + 'schematics.@schematics/angular.component.inlineStyle', |
| 31 | + 'true', |
| 32 | + ); |
| 33 | + } finally { |
| 34 | + process.chdir(cwd); |
| 35 | + } |
33 | 36 |
|
34 | | - output = await ng('config', '--global', 'schematics.@schematics/angular.component.inlineStyle'); |
35 | | - assert.match(output.stdout, /true\n?/); |
| 37 | + output = await ng('config', '--global', 'schematics.@schematics/angular.component.inlineStyle'); |
| 38 | + assert.match(output.stdout, /true\n?/); |
36 | 39 |
|
37 | | - await expectToFail(() => ng('config', '--global', 'cli.warnings.notreal', 'true')); |
| 40 | + await expectToFail(() => ng('config', '--global', 'cli.warnings.notreal', 'true')); |
38 | 41 |
|
39 | | - await ng('config', '--global', 'cli.warnings.versionMismatch', 'false'); |
40 | | - await expectFileToExist(path.join(homedir(), '.angular-config.json')); |
41 | | - await deleteFile(path.join(homedir(), '.angular-config.json')); |
| 42 | + await ng('config', '--global', 'cli.warnings.versionMismatch', 'false'); |
| 43 | + await expectFileToExist(globalConfigPath); |
| 44 | + } finally { |
| 45 | + await deleteFile(globalConfigPath).catch(() => {}); |
| 46 | + } |
42 | 47 | } |
0 commit comments