Comparing version
@@ -1,4 +0,4 @@ | ||
## [6.2.4](https://github.com/jondot/hygen/compare/v6.2.0...v6.2.4) (2022-06-03) | ||
## [6.2.5](https://github.com/jondot/hygen/compare/v6.2.0...v6.2.5) (2022-06-05) | ||
@@ -8,12 +8,17 @@ "use strict"; | ||
const localsToCapitalize = ['name']; | ||
const localsToPluralize = ['name']; | ||
const localsDefaults = { | ||
name: 'unnamed', | ||
}; | ||
const doCapitalization = (hsh, [key, value]) => { | ||
const processLocals = (hsh, [key, value]) => { | ||
hsh[key] = value; | ||
if (localsToCapitalize.includes(key)) | ||
if (localsToCapitalize.includes(key)) { | ||
hsh[helpers_1.default.capitalize(key)] = helpers_1.default.capitalize(value); | ||
} | ||
if (localsToPluralize.includes(key)) { | ||
hsh[helpers_1.default.inflection.pluralize(key)] = helpers_1.default.inflection.pluralize(value); | ||
} | ||
return hsh; | ||
}; | ||
const capitalizedLocals = (locals) => Object.entries(locals).reduce(doCapitalization, {}); | ||
const processedLocals = (locals) => Object.entries(locals).reduce(processLocals, {}); | ||
const context = (locals, config = {}) => { | ||
@@ -26,3 +31,3 @@ const localsWithDefaults = Object.assign(Object.assign(Object.assign({}, localsDefaults), config.localsDefaults), locals); | ||
{}; | ||
return Object.assign(localsWithDefaults, capitalizedLocals(localsWithDefaults), { | ||
return Object.assign(localsWithDefaults, processedLocals(localsWithDefaults), { | ||
h: Object.assign(Object.assign({}, helpers_1.default), configHelpers), | ||
@@ -29,0 +34,0 @@ }); |
{ | ||
"name": "hygen", | ||
"version": "6.2.4", | ||
"version": "6.2.5", | ||
"description": "The scalable code generator that saves you time.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -5,2 +5,3 @@ import type { RunnerConfig } from './types' | ||
const localsToCapitalize = ['name'] | ||
const localsToPluralize = ['name'] | ||
const localsDefaults = { | ||
@@ -10,13 +11,18 @@ name: 'unnamed', | ||
const doCapitalization = (hsh, [key, value]) => { | ||
const processLocals = (hsh, [key, value]) => { | ||
hsh[key] = value | ||
if (localsToCapitalize.includes(key)) | ||
if (localsToCapitalize.includes(key)) { | ||
hsh[helpers.capitalize(key)] = helpers.capitalize(value) | ||
} | ||
if (localsToPluralize.includes(key)) { | ||
hsh[helpers.inflection.pluralize(key)] = helpers.inflection.pluralize(value) | ||
} | ||
return hsh | ||
} | ||
const capitalizedLocals = (locals: any) => | ||
Object.entries(locals).reduce(doCapitalization, {}) | ||
const processedLocals = (locals: any) => | ||
Object.entries(locals).reduce(processLocals, {}) | ||
@@ -37,3 +43,3 @@ const context = (locals: any, config: RunnerConfig = {}) => { | ||
localsWithDefaults, | ||
capitalizedLocals(localsWithDefaults), | ||
processedLocals(localsWithDefaults), | ||
{ | ||
@@ -40,0 +46,0 @@ h: { ...helpers, ...configHelpers }, |
Sorry, the diff of this file is not supported yet
136503
0.25%2158
0.47%