Skip to content

Commit

Permalink
Added outExt generation config key (see #53)
Browse files Browse the repository at this point in the history
  • Loading branch information
jawj committed Jan 4, 2021
1 parent 76be8d7 commit d646219
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/generate/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -43,6 +44,7 @@ export type CompleteConfig = RequiredConfig & OptionalConfig;

const defaultConfig: OptionalConfig = {
outDir: '.',
outExt: '.d.ts',
schemas: { public: { include: '*', exclude: [] } },
progressListener: false,
warningListener: true,
Expand Down
6 changes: 3 additions & 3 deletions src/generate/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' { }
Expand All @@ -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}`);

Expand Down

0 comments on commit d646219

Please sign in to comment.