Skip to content

Commit

Permalink
feat(cli): add build option to not include the header in dts file (#1140
Browse files Browse the repository at this point in the history
)

* Add build option to not include the header in dts file

* Fix lint
  • Loading branch information
ceifa committed Apr 22, 2022
1 parent 4f422b6 commit c390609
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cli/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export class BuildCommand extends Command {
)} file, relative to cwd`,
})

noDtsHeader = Option.Boolean('--no-dts-header', false, {
description: `Don't generate ${chalk.green('.d.ts')} header`,
})

project = Option.String('-p', {
description: `Bypass to ${chalk.green('cargo -p')}`,
})
Expand Down Expand Up @@ -497,6 +501,7 @@ export class BuildCommand extends Command {
const idents = await processIntermediateTypeFile(
intermediateTypeFile,
dtsFilePath,
this.noDtsHeader,
)
await writeJsBinding(
binaryName,
Expand Down Expand Up @@ -545,6 +550,7 @@ interface TypeDef {
async function processIntermediateTypeFile(
source: string,
target: string,
noDtsHeader: boolean,
): Promise<string[]> {
const idents: string[] = []
if (!existsSync(source)) {
Expand Down Expand Up @@ -654,7 +660,9 @@ async function processIntermediateTypeFile(
return acc + `export namespace ${mod} {\n${convertDefs(defs, true)}}\n`
}, '')

const dtsHeader = `/* tslint:disable */
const dtsHeader = noDtsHeader
? ''
: `/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */\n
Expand Down

0 comments on commit c390609

Please sign in to comment.