Skip to content

Commit 8d70785

Browse files
committed
wip: revert part
1 parent 85508bd commit 8d70785

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

tests/legacy-cli/e2e/setup/002-npm-sandbox.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export default async function () {
1414
process.env.NPM_CONFIG_USERCONFIG = npmrc;
1515
process.env.NPM_CONFIG_PREFIX = npmModulesPrefix;
1616

17-
// Ensure the directory + files exists
18-
await writeFile(npmrc, '');
17+
// Ensure the directory + files exists, configure th registry in the npmrc
18+
await writeFile(npmrc, 'registry=' + getGlobalVariable('package-registry'));
1919
await mkdir(npmModulesPrefix);
2020

2121
// Ensure the custom npm global bin is first on the PATH

tests/legacy-cli/e2e/setup/500-create-project.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { join } from 'path';
22
import { getGlobalVariable } from '../utils/env';
3-
import { expectFileToExist } from '../utils/fs';
3+
import { expectFileToExist, writeFile } from '../utils/fs';
44
import { gitClean } from '../utils/git';
5-
import { setRegistry as setNPMConfigRegistry, setRegistry } from '../utils/packages';
6-
import { ng } from '../utils/process';
5+
import { setRegistry as setNPMConfigRegistry } from '../utils/packages';
6+
import { ng, npm } from '../utils/process';
77
import { prepareProjectForE2e, updateJsonFile } from '../utils/project';
88

99
export default async function () {
@@ -18,6 +18,8 @@ export default async function () {
1818
await gitClean();
1919
} else {
2020
const extraArgs = [];
21+
const testRegistry = getGlobalVariable('package-registry');
22+
const isCI = getGlobalVariable('ci');
2123

2224
// Ensure local test registry is used when outside a project
2325
await setNPMConfigRegistry(true);
@@ -26,7 +28,11 @@ export default async function () {
2628
await expectFileToExist(join(process.cwd(), 'test-project'));
2729
process.chdir('./test-project');
2830

29-
setRegistry(true);
31+
// If on CI, the user configuration set above will handle project usage
32+
if (!isCI) {
33+
// Ensure local test registry is used inside a project
34+
await writeFile('.npmrc', `registry=${testRegistry}`);
35+
}
3036

3137
// Setup esbuild builder if requested on the commandline
3238
const useEsbuildBuilder = !!getGlobalVariable('argv')['esbuild'];

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getGlobalVariable } from './env';
2-
import { ProcessOutput, silentNpm, silentYarn } from './process';
2+
import { ProcessOutput, npm, silentNpm, silentYarn } from './process';
33

44
export function getActivePackageManager(): 'npm' | 'yarn' {
55
const value = getGlobalVariable('package-manager');
@@ -49,11 +49,17 @@ export async function setRegistry(useTestRegistry: boolean): Promise<void> {
4949
? getGlobalVariable('package-registry')
5050
: 'https://registry.npmjs.org';
5151

52+
const isCI = getGlobalVariable('ci');
5253
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
5354

5455
// Ensure local test registry is used when outside a project
55-
// Yarn supports both `NPM_CONFIG_REGISTRY` and `YARN_REGISTRY`.
56-
process.env['NPM_CONFIG_REGISTRY'] = url;
56+
if (isCI) {
57+
// Safe to set a user configuration on CI
58+
await npm('config', 'set', 'registry', url);
59+
} else {
60+
// Yarn supports both `NPM_CONFIG_REGISTRY` and `YARN_REGISTRY`.
61+
process.env['NPM_CONFIG_REGISTRY'] = url;
62+
}
5763

5864
// Snapshot builds may contain versions that are not yet released (e.g., RC phase main branch).
5965
// In this case peer dependency ranges may not resolve causing npm 7+ to fail during tests.

0 commit comments

Comments
 (0)