From d6462197a781470b663873b6d5654287270fcb92 Mon Sep 17 00:00:00 2001 From: George MacKerron Date: Mon, 4 Jan 2021 17:23:08 +0000 Subject: [PATCH] Added outExt generation config key (see #53) --- src/generate/config.ts | 2 ++ src/generate/write.ts | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/generate/config.ts b/src/generate/config.ts index 4b5ad7f..64fc57f 100644 --- a/src/generate/config.ts +++ b/src/generate/config.ts @@ -15,6 +15,7 @@ export interface RequiredConfig { export interface OptionalConfig { outDir: string; + outExt: string; schemas: SchemaRules; progressListener: boolean | ((s: string) => void); warningListener: boolean | ((s: string) => void); @@ -43,6 +44,7 @@ export type CompleteConfig = RequiredConfig & OptionalConfig; const defaultConfig: OptionalConfig = { outDir: '.', + outExt: '.d.ts', schemas: { public: { include: '*', exclude: [] } }, progressListener: false, warningListener: true, diff --git a/src/generate/write.ts b/src/generate/write.ts index cb04117..2b548bd 100644 --- a/src/generate/write.ts +++ b/src/generate/write.ts @@ -26,11 +26,11 @@ export const generate = async (suppliedConfig: Config) => { { ts, customTypeSourceFiles } = await tsForConfig(config), folderName = 'zapatos', - schemaName = 'schema.d.ts', + schemaName = 'schema' + config.outExt, customFolderName = 'custom', eslintrcName = '.eslintrc.json', eslintrcContent = '{\n "ignorePatterns": [\n "*"\n ]\n}', - customTypesIndexName = 'index.d.ts', + customTypesIndexName = 'index' + config.outExt, customTypesIndexContent = header() + ` // this empty declaration appears to fix relative imports in other custom type files declare module 'zapatos/custom' { } @@ -55,7 +55,7 @@ declare module 'zapatos/custom' { } fs.mkdirSync(customFolderTargetPath, { recursive: true }); for (const customTypeFileName in customTypeSourceFiles) { - const customTypeFilePath = path.join(customFolderTargetPath, customTypeFileName + '.d.ts'); + const customTypeFilePath = path.join(customFolderTargetPath, customTypeFileName + config.outExt); if (fs.existsSync(customTypeFilePath)) { log(`Custom type or domain declaration file already exists: ${customTypeFilePath}`);