feat(cli): provide a way to override the native package name
This commit is contained in:
parent
46168ee6d6
commit
046f75dc29
2 changed files with 15 additions and 3 deletions
|
@ -79,6 +79,13 @@ export class BuildCommand extends Command {
|
||||||
)} to disable it. Only affect if ${chalk.green('--target')} specified.`,
|
)} to disable it. Only affect if ${chalk.green('--target')} specified.`,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
jsPackageName = Option.String('--js-package-name', {
|
||||||
|
description: `Package name in generated js binding file, Only affect if ${chalk.green(
|
||||||
|
'--target',
|
||||||
|
)} specified and ${chalk.green('--js')} is not false.`,
|
||||||
|
required: false,
|
||||||
|
})
|
||||||
|
|
||||||
cargoCwd?: string = Option.String('--cargo-cwd', {
|
cargoCwd?: string = Option.String('--cargo-cwd', {
|
||||||
description: `The cwd of ${chalk.underline(
|
description: `The cwd of ${chalk.underline(
|
||||||
chalk.yellow('Cargo.toml'),
|
chalk.yellow('Cargo.toml'),
|
||||||
|
@ -304,7 +311,12 @@ export class BuildCommand extends Command {
|
||||||
this.appendPlatformToFilename
|
this.appendPlatformToFilename
|
||||||
? join(process.cwd(), this.jsBinding)
|
? join(process.cwd(), this.jsBinding)
|
||||||
: null
|
: null
|
||||||
await writeJsBinding(binaryName, packageName, jsBindingFilePath, idents)
|
await writeJsBinding(
|
||||||
|
binaryName,
|
||||||
|
this.jsPackageName ?? packageName,
|
||||||
|
jsBindingFilePath,
|
||||||
|
idents,
|
||||||
|
)
|
||||||
if (this.pipe && jsBindingFilePath) {
|
if (this.pipe && jsBindingFilePath) {
|
||||||
const pipeCommand = `${this.pipe} ${jsBindingFilePath}`
|
const pipeCommand = `${this.pipe} ${jsBindingFilePath}`
|
||||||
console.info(`Run ${chalk.green(pipeCommand)}`)
|
console.info(`Run ${chalk.green(pipeCommand)}`)
|
||||||
|
|
|
@ -18,10 +18,10 @@ export function getNapiConfig(
|
||||||
const platforms = [...defaultPlatforms, ...additionPlatforms]
|
const platforms = [...defaultPlatforms, ...additionPlatforms]
|
||||||
const releaseVersion = process.env.RELEASE_VERSION
|
const releaseVersion = process.env.RELEASE_VERSION
|
||||||
const releaseVersionWithoutPrefix = releaseVersion?.startsWith('v')
|
const releaseVersionWithoutPrefix = releaseVersion?.startsWith('v')
|
||||||
? releaseVersion.substr(1)
|
? releaseVersion.substring(1)
|
||||||
: releaseVersion
|
: releaseVersion
|
||||||
const version = releaseVersionWithoutPrefix ?? packageVersion
|
const version = releaseVersionWithoutPrefix ?? packageVersion
|
||||||
const packageName = name
|
const packageName = napi?.package?.name ?? name
|
||||||
|
|
||||||
const binaryName: string = napi?.name ?? 'index'
|
const binaryName: string = napi?.name ?? 'index'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue