From c39060984d4cae560da7c1a7994ba6c1e33fa101 Mon Sep 17 00:00:00 2001 From: Gabriel Francisco Date: Fri, 22 Apr 2022 05:52:43 -0300 Subject: [PATCH] feat(cli): add build option to not include the header in dts file (#1140) * Add build option to not include the header in dts file * Fix lint --- cli/src/build.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cli/src/build.ts b/cli/src/build.ts index e1f6ee4d..6ac79586 100644 --- a/cli/src/build.ts +++ b/cli/src/build.ts @@ -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')}`, }) @@ -497,6 +501,7 @@ export class BuildCommand extends Command { const idents = await processIntermediateTypeFile( intermediateTypeFile, dtsFilePath, + this.noDtsHeader, ) await writeJsBinding( binaryName, @@ -545,6 +550,7 @@ interface TypeDef { async function processIntermediateTypeFile( source: string, target: string, + noDtsHeader: boolean, ): Promise { const idents: string[] = [] if (!existsSync(source)) { @@ -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