Skip to content

Commit

Permalink
adjust teardown and setup logic
Browse files Browse the repository at this point in the history
  • Loading branch information
BioPhoton committed Sep 11, 2024
1 parent c08b36d commit 3b6cb7d
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions tools/src/verdaccio/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,26 @@ export function configureRegistry(
}

export function unconfigureRegistry(
{ urlNoProtocol }: Pick<Registry, 'urlNoProtocol'>,
{
urlNoProtocol,
userconfig,
}: Pick<Registry, 'urlNoProtocol'> & Pick<VerdaccioEnv, 'userconfig'>,
verbose?: boolean,
) {
execSync(`npm config delete registry`);
execSync(`npm config delete ${urlNoProtocol}/:_authToken`);
execSync(`npm config delete registry --userconfig ${userconfig}`);
execSync(
`npm config delete ${urlNoProtocol}/:_authToken --userconfig ${userconfig}`,
);
if (verbose) {
console.info(`${gray('>')} ${gray(bold('Verdaccio-Env'))} delete registry`);
console.info(
`${gray('>')} ${gray(
bold('Verdaccio-Env'),
)} delete npm authToken: ${urlNoProtocol}`,
)} delete registry from ${userconfig}`,
);
console.info(
`${gray('>')} ${gray(
bold('Verdaccio-Env'),
)} delete npm authToken: ${urlNoProtocol} from ${userconfig}`,
);
}
}
Expand Down Expand Up @@ -151,6 +160,8 @@ export async function nxStartVerdaccioAndSetupEnv({

export async function nxStopVerdaccioAndTeardownEnv(
result: VerdaccioEnvResult,
teardownWorkspaceRoot = true,
teardownStorage = true,
) {
if (result) {
const { stop, registry, workspaceRoot } = result;
Expand All @@ -165,7 +176,12 @@ export async function nxStopVerdaccioAndTeardownEnv(
} else {
console.error('Stop is not a function. Type:', typeof stop);
}
await teardownTestFolder(workspaceRoot);

if (teardownWorkspaceRoot) {
await teardownTestFolder(workspaceRoot);
} else if (teardownStorage) {
await teardownTestFolder(result.registry.storage);
}
} else {
throw new Error(`Failed to stop registry.`);
}
Expand Down

0 comments on commit 3b6cb7d

Please sign in to comment.