Skip to content

Commit

Permalink
typescript-fetch: Only generate npm package if npmName specified (#4472)
Browse files Browse the repository at this point in the history
* Only generate npm package if npmName specified

* additionalProperties not available in constructor
  • Loading branch information
rob-deutsch authored and macjohnny committed Nov 13, 2019
1 parent bdd34a3 commit 64c1547
Show file tree
Hide file tree
Showing 46 changed files with 13 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ public TypeScriptFetchClientCodegen() {
outputFolder = "generated-code/typescript-fetch";
embeddedTemplateDir = templateDir = "typescript-fetch";

this.apiPackage = "src" + File.separator +"apis";
this.modelPackage = "src" + File.separator + "models";
this.apiTemplateFiles.put("apis.mustache", ".ts");
this.modelTemplateFiles.put("models.mustache", ".ts");
this.addExtraReservedWords();
Expand Down Expand Up @@ -98,10 +96,17 @@ public void processOpts() {
super.processOpts();
additionalProperties.put("isOriginalModelPropertyNaming", getModelPropertyNaming().equals("original"));
additionalProperties.put("modelPropertyNaming", getModelPropertyNaming());
supportingFiles.add(new SupportingFile("index.mustache", "src", "index.ts"));
supportingFiles.add(new SupportingFile("runtime.mustache", "src", "runtime.ts"));
supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));

String sourceDir = "";
if (additionalProperties.containsKey(NPM_NAME)) {
sourceDir = "src" + File.separator;
}

this.apiPackage = sourceDir + "apis";
this.modelPackage = sourceDir + "models";

supportingFiles.add(new SupportingFile("index.mustache", sourceDir, "index.ts"));
supportingFiles.add(new SupportingFile("runtime.mustache", sourceDir, "runtime.ts"));

if (additionalProperties.containsKey(USE_SINGLE_REQUEST_PARAMETER)) {
this.setUseSingleRequestParameter(convertPropertyToBoolean(USE_SINGLE_REQUEST_PARAMETER));
Expand Down Expand Up @@ -211,7 +216,9 @@ private void addNpmPackageGeneration() {
//Files for building our lib
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
supportingFiles.add(new SupportingFile("npmignore.mustache", "", ".npmignore"));
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
}

@Override
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 64c1547

Please sign in to comment.