From 6fa2110c95db15f91864cf4b37b2efdd2082a52d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BChler?= Date: Tue, 11 Jul 2017 07:48:25 +0200 Subject: [PATCH 1/3] feat(generator): make generators extendable --- src/code-generators/TypescriptCodeGenerator.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/code-generators/TypescriptCodeGenerator.ts b/src/code-generators/TypescriptCodeGenerator.ts index c9c819b..91d5176 100644 --- a/src/code-generators/TypescriptCodeGenerator.ts +++ b/src/code-generators/TypescriptCodeGenerator.ts @@ -30,9 +30,15 @@ import { TypescriptGenerationOptions } from './TypescriptGenerationOptions'; */ export type Generatable = Declaration | Import | Export | SymbolSpecifier; -type Generators = { [name: string]: (generatable: Generatable, options: TypescriptGenerationOptions) => string }; +/** + * Type for generators. + */ +export type Generators = { [name: string]: (generatable: Generatable, options: TypescriptGenerationOptions) => string }; -const generators: Generators = { +/** + * Hash with all possible (yet implemented) generators. + */ +export const generators: Generators = { [SymbolSpecifier.name]: generateSymbolSpecifier, [MethodDeclaration.name]: generateMethodDeclaration, [ParameterDeclaration.name]: generateParameterDeclaration, From 921f475ea47e4ac74bbd2c98e2c58247c6c8fc71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BChler?= Date: Tue, 11 Jul 2017 07:49:43 +0200 Subject: [PATCH 2/3] chore: remove semantic release github --- package.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/package.json b/package.json index 4fbe2d0..601d287 100644 --- a/package.json +++ b/package.json @@ -30,15 +30,11 @@ "url": "https://github.com/TypeScript-Heroes/node-typescript-parser/issues" }, "homepage": "https://github.com/TypeScript-Heroes/node-typescript-parser#readme", - "release": { - "generateNotes": "github-post-release" - }, "devDependencies": { "@types/jest": "^20.0.1", "@types/mock-fs": "^3.6.30", "@types/node": "^8.0.1", "del-cli": "^1.0.0", - "github-post-release": "^1.7.1", "jest": "^20.0.4", "mock-fs": "^4.4.1", "semantic-release": "^6.3.6", From b87cc20b1551cf34312ae7754a3b450f51994b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BChler?= Date: Tue, 11 Jul 2017 07:50:42 +0200 Subject: [PATCH 3/3] style: rename const --- src/code-generators/TypescriptCodeGenerator.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/code-generators/TypescriptCodeGenerator.ts b/src/code-generators/TypescriptCodeGenerator.ts index 91d5176..f9b6eec 100644 --- a/src/code-generators/TypescriptCodeGenerator.ts +++ b/src/code-generators/TypescriptCodeGenerator.ts @@ -38,7 +38,7 @@ export type Generators = { [name: string]: (generatable: Generatable, options: T /** * Hash with all possible (yet implemented) generators. */ -export const generators: Generators = { +export const GENERATORS: Generators = { [SymbolSpecifier.name]: generateSymbolSpecifier, [MethodDeclaration.name]: generateMethodDeclaration, [ParameterDeclaration.name]: generateParameterDeclaration, @@ -69,8 +69,8 @@ export class TypescriptCodeGenerator { * @memberof TypescriptCodeGenerator */ public generate(declaration: Generatable): string { - if (generators[declaration.constructor.name]) { - return generators[declaration.constructor.name](declaration, this.options); + if (GENERATORS[declaration.constructor.name]) { + return GENERATORS[declaration.constructor.name](declaration, this.options); } throw new NotGeneratableYetError(declaration); }