Skip to content

Commit f6d1c67

Browse files
js2mearmsnyder
andauthored
Release 5.1.7 (#180)
* Do not fail if template file does not exist (#179) This allows overriding specific template files and fallback on the defaults. * bump: up version to 5.1.7 Co-authored-by: Adam Snyder <[email protected]>
1 parent 0efc754 commit f6d1c67

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# next release
22

3+
# 5.1.7
4+
5+
Fixes:
6+
- Do not fail if template file does not exist (issue #166, thanks @armsnyder )
7+
Caveat: With this fix it will still error if the overridden template uses `includeFile` on a template file that is not overridden
8+
39
# 5.1.6
410

511
Fixes:

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "swagger-typescript-api",
3-
"version": "5.1.6",
3+
"version": "5.1.7",
44
"description": "Create typescript api module from swagger schema",
55
"scripts": {
66
"cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts --extract-request-params --enum-names-as-values",

src/templates.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const _ = require("lodash");
22
const Eta = require("eta");
3-
const { getFileContent } = require("./files");
3+
const { getFileContent, pathIsExist } = require("./files");
44
const { resolve } = require("path");
55

66
const getTemplates = ({ templates, modular }) => {
@@ -27,7 +27,8 @@ const getTemplates = ({ templates, modular }) => {
2727
const templatesMap = _.reduce(
2828
templatePaths,
2929
(acc, pathToTemplate, key) => {
30-
let fileContent = getFileContent(resolve(customTemplatesPath, pathToTemplate));
30+
const customFullPath = resolve(customTemplatesPath, pathToTemplate)
31+
let fileContent = pathIsExist(customFullPath) && getFileContent(customFullPath);
3132

3233
if (!fileContent) {
3334
console.log(

0 commit comments

Comments
 (0)