Skip to content

Commit 2299ad4

Browse files
alan-agius4vikerman
authored andcommitted
test: add local npm registry that require local built packages
1 parent 3dd3529 commit 2299ad4

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

tests/legacy-cli/e2e/tests/misc/ask-analytics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default async function() {
1717
// Install the CLI with TTY force enabled
1818
const execution = execWithEnv(
1919
'npm',
20-
['install', packages['@angular/cli'].tar],
20+
['install', packages['@angular/cli'].tar, '--registry=http://localhost:4873'],
2121
{ ...process.env, 'NG_FORCE_TTY': '1' },
2222
);
2323

tests/legacy-cli/e2e/tests/schematics_cli/basic.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ export default async function () {
1212
}
1313

1414
const startCwd = process.cwd();
15-
await silentNpm('install', '-g', packages['@angular-devkit/schematics-cli'].tar, '--unsafe-perm');
15+
await silentNpm(
16+
'install',
17+
'-g',
18+
packages['@angular-devkit/schematics-cli'].tar,
19+
'--unsafe-perm',
20+
'--registry=http://localhost:4873',
21+
);
1622
await exec(process.platform.startsWith('win') ? 'where' : 'which', 'schematics');
1723

1824
// create blank schematic

tests/legacy-cli/e2e/tests/update/update-1.0.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as fs from 'fs';
21
import { createProjectFromAsset } from '../../utils/assets';
32
import { ng, silentNpm } from '../../utils/process';
43
import { isPrereleaseCli, useBuiltPackages, useCIChrome, useCIDefaults } from '../../utils/project';
@@ -8,7 +7,6 @@ export default async function() {
87
const extraUpdateArgs = (await isPrereleaseCli()) ? ['--next', '--force'] : [];
98

109
await createProjectFromAsset('1.0-project');
11-
fs.writeFileSync('.npmrc', 'registry = http://localhost:4873', 'utf8');
1210

1311
await useCIChrome('.');
1412
await expectToFail(() => ng('build'));

tests/legacy-cli/e2e/tests/update/update-1.7-longhand.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as fs from 'fs';
21
import { createProjectFromAsset } from '../../utils/assets';
32
import { ng, silentNpm } from '../../utils/process';
43
import { isPrereleaseCli, useBuiltPackages } from '../../utils/project';
@@ -8,7 +7,6 @@ export default async function() {
87
const extraUpdateArgs = (await isPrereleaseCli()) ? ['--next', '--force'] : [];
98

109
await createProjectFromAsset('1.7-project');
11-
fs.writeFileSync('.npmrc', 'registry = http://localhost:4873', 'utf8');
1210

1311
await expectToFail(() => ng('build'));
1412
await ng('update', '@angular/cli', '--migrate-only', '--from=1.7.1');

tests/legacy-cli/e2e/utils/assets.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {join} from 'path';
22
import * as glob from 'glob';
33
import {getGlobalVariable} from './env';
44
import {relative} from 'path';
5-
import {copyFile} from './fs';
5+
import {copyFile, writeFile} from './fs';
66
import {useBuiltPackages} from './project';
77
import { git, silentNpm } from './process';
88

@@ -39,10 +39,12 @@ export function copyAssets(assetName: string) {
3939
}
4040

4141

42-
export function createProjectFromAsset(assetName: string, useNpmPackages = false) {
43-
return Promise.resolve()
44-
.then(() => copyAssets(assetName))
45-
.then(dir => process.chdir(dir))
46-
.then(() => useNpmPackages ? null : useBuiltPackages())
47-
.then(() => silentNpm('install'));
42+
export async function createProjectFromAsset(assetName: string, useNpmPackages = false) {
43+
const dir = await copyAssets(assetName);
44+
process.chdir(dir);
45+
if (!useNpmPackages) {
46+
await useBuiltPackages();
47+
await writeFile('.npmrc', 'registry = http://localhost:4873', 'utf8');
48+
}
49+
await silentNpm('install');
4850
}

0 commit comments

Comments
 (0)