feat(cli): dts flag for build command
This commit is contained in:
parent
e69a763284
commit
0e8de173a4
4 changed files with 7 additions and 18 deletions
|
@ -38,6 +38,8 @@ export class BuildCommand extends Command {
|
||||||
|
|
||||||
features?: string = Option.String('--features')
|
features?: string = Option.String('--features')
|
||||||
|
|
||||||
|
dts?: string = Option.String('--dts')
|
||||||
|
|
||||||
cargoFlags = Option.String('--cargo-flags', '')
|
cargoFlags = Option.String('--cargo-flags', '')
|
||||||
|
|
||||||
cargoCwd?: string = Option.String('--cargo-cwd')
|
cargoCwd?: string = Option.String('--cargo-cwd')
|
||||||
|
@ -198,7 +200,7 @@ export class BuildCommand extends Command {
|
||||||
|
|
||||||
await processIntermediateTypeFile(
|
await processIntermediateTypeFile(
|
||||||
intermediateTypeFile,
|
intermediateTypeFile,
|
||||||
join(this.destDir ?? '.', 'type.d.ts'),
|
join(this.destDir ?? '.', this.dts ?? 'index.d.ts'),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,5 +4,5 @@ import { join } from 'path'
|
||||||
import test from 'ava'
|
import test from 'ava'
|
||||||
|
|
||||||
test('should generate correct type def file', (t) => {
|
test('should generate correct type def file', (t) => {
|
||||||
t.snapshot(readFileSync(join(__dirname, '..', 'type.d.ts'), 'utf8'))
|
t.snapshot(readFileSync(join(__dirname, '..', 'index.d.ts'), 'utf8'))
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,21 +2,8 @@ export function getWords(): Array<string>
|
||||||
export function getNums(): Array<number>
|
export function getNums(): Array<number>
|
||||||
export function sumNums(nums: Array<number>): number
|
export function sumNums(nums: Array<number>): number
|
||||||
export function getCwd(callback: (arg0: string) => void): void
|
export function getCwd(callback: (arg0: string) => void): void
|
||||||
export enum Kind {
|
export enum Kind { Dog = 0, Cat = 1, Duck = 2 }
|
||||||
Dog = 0,
|
export enum CustomNumEnum { One = 1, Two = 2, Three = 3, Four = 4, Six = 6, Eight = 8, Nine = 9, Ten = 10 }
|
||||||
Cat = 1,
|
|
||||||
Duck = 2,
|
|
||||||
}
|
|
||||||
export enum CustomNumEnum {
|
|
||||||
One = 1,
|
|
||||||
Two = 2,
|
|
||||||
Three = 3,
|
|
||||||
Four = 4,
|
|
||||||
Six = 6,
|
|
||||||
Eight = 8,
|
|
||||||
Nine = 9,
|
|
||||||
Ten = 10,
|
|
||||||
}
|
|
||||||
export function enumToI32(e: CustomNumEnum): number
|
export function enumToI32(e: CustomNumEnum): number
|
||||||
export function mapOption(val: number | undefined): number | undefined
|
export function mapOption(val: number | undefined): number | undefined
|
||||||
export function add(a: number, b: number): number
|
export function add(a: number, b: number): number
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "napi-examples",
|
"name": "napi-examples",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "./index.node",
|
"main": "./index.node",
|
||||||
"types": "./type.d.ts",
|
"types": "./index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node ../../cli/scripts/index.js build --features \"latest\"",
|
"build": "node ../../cli/scripts/index.js build --features \"latest\"",
|
||||||
"build-napi3": "node ../../cli/scripts/index.js build --features \"napi3\"",
|
"build-napi3": "node ../../cli/scripts/index.js build --features \"napi3\"",
|
||||||
|
|
Loading…
Reference in a new issue