-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathversion-specifier.ts
More file actions
53 lines (44 loc) · 1.96 KB
/
version-specifier.ts
File metadata and controls
53 lines (44 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import assert from 'node:assert/strict';
import { appendFile } from 'node:fs/promises';
import { expectFileToMatch } from '../../../utils/fs';
import { getActivePackageManager, uninstallPackage } from '../../../utils/packages';
import { ng } from '../../../utils/process';
import { isPrereleaseCli } from '../../../utils/project';
export default async function () {
// forcibly remove in case another test doesn't clean itself up.
await uninstallPackage('@angular/localize');
// If using npm, enable the legacy-peer-deps option to allow testing the output behavior of the
// `ng add` command itself and not the behavior of npm which may otherwise fail depending
// on the npm version in use and the version specifier supplied in each test.
if (getActivePackageManager() === 'npm') {
await appendFile('.npmrc', '\nlegacy-peer-deps=true\n');
}
const tag = isPrereleaseCli() ? '@next' : '';
await ng('add', `@angular/localize${tag}`, '--skip-confirmation');
await expectFileToMatch('package.json', /@angular\/localize/);
const output1 = await ng('add', '@angular/localize', '--skip-confirmation');
assert.match(
output1.stdout,
/Skipping installation: Package already installed/,
'Installation was not skipped',
);
const output2 = await ng('add', '@angular/localize@latest', '--skip-confirmation');
assert.doesNotMatch(
output2.stdout,
/Skipping installation: Package already installed/,
'Installation should not have been skipped',
);
const output3 = await ng('add', '@angular/localize@19.1.0', '--skip-confirmation');
assert.doesNotMatch(
output3.stdout,
/Skipping installation: Package already installed/,
'Installation should not have been skipped',
);
const output4 = await ng('add', '@angular/localize@19', '--skip-confirmation');
assert.match(
output4.stdout,
/Skipping installation: Package already installed/,
'Installation was not skipped',
);
await uninstallPackage('@angular/localize');
}