feat: support --cargo-name config in napi cli
This commit is contained in:
parent
9c45704eae
commit
4226561c7e
1 changed files with 27 additions and 23 deletions
|
@ -28,6 +28,9 @@ export class BuildCommand extends Command {
|
|||
@Command.String('--config,-c')
|
||||
configFileName?: string
|
||||
|
||||
@Command.String('--cargo-name')
|
||||
cargoName?: string
|
||||
|
||||
@Command.String({
|
||||
required: false,
|
||||
})
|
||||
|
@ -36,6 +39,8 @@ export class BuildCommand extends Command {
|
|||
@Command.Path('build')
|
||||
async execute() {
|
||||
const { binaryName } = getNapiConfig(this.configFileName)
|
||||
let dylibName = this.cargoName
|
||||
if (!dylibName) {
|
||||
let tomlContentString: string
|
||||
let tomlContent: any
|
||||
try {
|
||||
|
@ -55,13 +60,12 @@ export class BuildCommand extends Command {
|
|||
throw new TypeError('Could not parse the Cargo.toml')
|
||||
}
|
||||
|
||||
let dylibName
|
||||
|
||||
if (tomlContent.package ?? tomlContent.package.name) {
|
||||
dylibName = tomlContent.package.name.replace(/-/g, '_')
|
||||
} else {
|
||||
throw new TypeError('No package.name field in Cargo.toml')
|
||||
}
|
||||
}
|
||||
|
||||
debug(`Dylib name: ${chalk.greenBright(dylibName)}`)
|
||||
|
||||
|
|
Loading…
Reference in a new issue