feat(js): add location none to verdaccio executor (#17319)

This commit is contained in:
Emily Xiong 2023-05-31 08:37:24 -04:00 committed by GitHub
parent 646f79f4d2
commit 72b0f55605
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 4 deletions

View File

@ -13,7 +13,7 @@
"type": "string",
"description": "Location option for npm config",
"default": "user",
"enum": ["global", "user", "project"]
"enum": ["global", "user", "project", "none"]
},
"storage": {
"type": "string",

View File

@ -1,5 +1,5 @@
export interface VerdaccioExecutorSchema {
location?: string;
location: 'global' | 'user' | 'project' | 'none';
storage?: string;
port: number;
config?: string;

View File

@ -10,7 +10,7 @@
"type": "string",
"description": "Location option for npm config",
"default": "user",
"enum": ["global", "user", "project"]
"enum": ["global", "user", "project", "none"]
},
"storage": {
"type": "string",

View File

@ -25,7 +25,8 @@ export async function verdaccioExecutor(
if (options.clear && options.storage && existsSync(options.storage)) {
removeSync(options.storage);
}
const cleanupFunctions = [setupNpm(options), setupYarn(options)];
const cleanupFunctions =
options.location === 'none' ? [] : [setupNpm(options), setupYarn(options)];
const processExitListener = (signal?: number | NodeJS.Signals) => {
if (childProcess) {
@ -148,6 +149,9 @@ function setupNpm(options: VerdaccioExecutorSchema) {
} else {
execSync(`npm config delete registry --location ${options.location}`);
}
execSync(
`npm config delete //localhost:${options.port}/:_authToken --location ${options.location}`
);
} catch (e) {
throw new Error(`Failed to reset npm registry: ${e.message}`);
}