feat(cli): support npmClient config (#1253)

This commit is contained in:
LongYinan 2022-07-31 20:43:25 +08:00 committed by GitHub
parent e30019aa5c
commit cb6fffd73f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View file

@ -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,
}
}

View file

@ -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,
})