From cb6fffd73fce69afc3bb3b116729561c17e476b8 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sun, 31 Jul 2022 20:43:25 +0800 Subject: [PATCH] feat(cli): support npmClient config (#1253) --- cli/src/consts.ts | 2 ++ cli/src/pre-publish.ts | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cli/src/consts.ts b/cli/src/consts.ts index 66c74912..646cef3c 100644 --- a/cli/src/consts.ts +++ b/cli/src/consts.ts @@ -22,6 +22,7 @@ export function getNapiConfig( : releaseVersion const version = releaseVersionWithoutPrefix ?? packageVersion const packageName = napi?.package?.name ?? name + const npmClient: string = napi?.npmClient ?? 'npm' const binaryName: string = napi?.name ?? 'index' @@ -32,5 +33,6 @@ export function getNapiConfig( binaryName, packageJsonPath, content: pkgJson, + npmClient, } } diff --git a/cli/src/pre-publish.ts b/cli/src/pre-publish.ts index 6d8d9045..0051a975 100644 --- a/cli/src/pre-publish.ts +++ b/cli/src/pre-publish.ts @@ -38,8 +38,14 @@ export class PrePublishCommand extends Command { skipGHRelease = Option.Boolean('--skip-gh-release', false) async execute() { - const { packageJsonPath, platforms, version, packageName, binaryName } = - getNapiConfig(this.configFileName) + const { + packageJsonPath, + platforms, + version, + packageName, + binaryName, + npmClient, + } = getNapiConfig(this.configFileName) debug(`Update optionalDependencies in [${packageJsonPath}]`) if (!this.isDryRun) { await VersionCommand.updatePackageJson(this.prefix, this.configFileName) @@ -73,7 +79,7 @@ export class PrePublishCommand extends Command { console.warn(`[${chalk.yellowBright(dstPath)}] is not existed`) continue } - await spawn('npm publish', { + await spawn(`${npmClient} publish`, { cwd: pkgDir, env: process.env, })