Skip to content

Commit

Permalink
fix(core): ensure CNW works without .yarnrc with custom registry (#18937
Browse files Browse the repository at this point in the history
)
  • Loading branch information
meeroslav authored Oct 18, 2023
1 parent aa57429 commit 80ade93
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/create-nx-workspace/src/utils/package-manager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { execSync } from 'child_process';
import { existsSync, readFileSync, writeFileSync } from 'fs';
import { existsSync, writeFileSync } from 'fs';
import { join } from 'path';

/*
Expand Down
10 changes: 10 additions & 0 deletions packages/devkit/src/tasks/install-packages-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ export function installPackagesTask(
cwd: join(tree.root, cwd),
stdio: process.env.NX_GENERATE_QUIET === 'true' ? 'ignore' : 'inherit',
};
// ensure local registry from process is not interfering with the install
// when we start the process from temp folder the local registry would override the custom registry
if (
process.env.npm_config_registry &&
process.env.npm_config_registry.match(
/^https:\/\/registry\.(npmjs\.org|yarnpkg\.com)/
)
) {
delete process.env.npm_config_registry;
}
execSync(pmc.install, execSyncOptions);
}
}
10 changes: 10 additions & 0 deletions packages/nx/src/command-line/migrate/command-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ function runMigration() {
if (p === null) {
runLocalMigrate();
} else {
// ensure local registry from process is not interfering with the install
// when we start the process from temp folder the local registry would override the custom registry
if (
process.env.npm_config_registry &&
process.env.npm_config_registry.match(
/^https:\/\/registry\.(npmjs\.org|yarnpkg\.com)/
)
) {
delete process.env.npm_config_registry;
}
execSync(`${p} _migrate ${process.argv.slice(3).join(' ')}`, {
stdio: ['inherit', 'inherit', 'inherit'],
});
Expand Down

0 comments on commit 80ade93

Please sign in to comment.