Skip to content

Commit

Permalink
fix(js): restore registry for only localhost (#17999)
Browse files Browse the repository at this point in the history
(cherry picked from commit 8d5cfcc)
  • Loading branch information
xiongemi authored and FrozenPandaz committed Jul 7, 2023
1 parent 802243e commit 9e448fe
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/js/src/executors/verdaccio/verdaccio.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function setupNpm(options: VerdaccioExecutorSchema) {
return () => {};
}

let npmRegistryPath;
let npmRegistryPath: string;
try {
npmRegistryPath = execSync(
`npm config get registry --location ${options.location}`
Expand All @@ -154,7 +154,13 @@ function setupNpm(options: VerdaccioExecutorSchema) {

return () => {
try {
if (npmRegistryPath) {
const currentNpmRegistryPath = execSync(
`npm config get registry --location ${options.location}`
)
?.toString()
?.trim()
?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
if (npmRegistryPath && currentNpmRegistryPath.includes('localhost')) {
execSync(
`npm config set registry ${npmRegistryPath} --location ${options.location}`
);
Expand Down Expand Up @@ -240,7 +246,13 @@ function setupYarn(options: VerdaccioExecutorSchema) {

return () => {
try {
if (yarnRegistryPath) {
const currentYarnRegistryPath = execSync(
`yarn config get ${registryConfigName}`
)
?.toString()
?.trim()
?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
if (yarnRegistryPath && currentYarnRegistryPath.includes('localhost')) {
execSync(
`yarn config set ${registryConfigName} ${yarnRegistryPath}` +
(options.location === 'user' ? ' --home' : '')
Expand Down

0 comments on commit 9e448fe

Please sign in to comment.