From 0680279ed4bfce8cc2cb70e219d31f20dba31e6e Mon Sep 17 00:00:00 2001 From: Emily Xiong Date: Thu, 6 Jul 2023 10:50:24 -0400 Subject: [PATCH] fix(js): restore default registry for only localhost --- .../src/executors/verdaccio/verdaccio.impl.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/js/src/executors/verdaccio/verdaccio.impl.ts b/packages/js/src/executors/verdaccio/verdaccio.impl.ts index e1badd1decc50..69e835e571c7a 100644 --- a/packages/js/src/executors/verdaccio/verdaccio.impl.ts +++ b/packages/js/src/executors/verdaccio/verdaccio.impl.ts @@ -131,7 +131,7 @@ function setupNpm(options: VerdaccioExecutorSchema) { return () => {}; } - let npmRegistryPath; + let npmRegistryPath: string; try { npmRegistryPath = execSync( `npm config get registry --location ${options.location}` @@ -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}` ); @@ -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' : '')