nest-utilities-cli
Advanced tools
Comparing version 1.1.0 to 1.1.2
{ | ||
"name": "nest-utilities-cli", | ||
"version": "1.1.0", | ||
"version": "1.1.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -11,3 +11,3 @@ "use strict"; | ||
@Controller("{name}") | ||
@Controller("{controller}") | ||
export class {name}Controller extends CrudController<I{name}Model> { | ||
@@ -26,3 +26,4 @@ constructor(private readonly service: {name}Service) { | ||
.replace(/{name}/g, name) | ||
.replace(/{controller}/g, string_utils_1.StringUtils.hyphenate(name)) | ||
.replace(/{servicePath}/g, string_utils_1.StringUtils.pathToImport(servicePath)) | ||
.replace(/{schemaPath}/g, string_utils_1.StringUtils.pathToImport(schemaPath)); |
@@ -9,3 +9,13 @@ "use strict"; | ||
} | ||
static hyphenate(value) { | ||
const text = value + "A"; | ||
const words = []; | ||
for (let i = 1; i < text.length; i++) { | ||
if (text[i] === text[i].toUpperCase()) { | ||
words.push(text.substring(words.join("").length, i).toLowerCase()); | ||
} | ||
} | ||
return words.join("-"); | ||
} | ||
} | ||
exports.StringUtils = StringUtils; |
17663
323