UNPKG

@nstudio/schematics

Version:

Cross-platform (xplat) tools for Nx workspaces.

48 lines 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * @license * Copyright (c) 2018 Narwhal Technologies Inc. * * Use of this source code is governed by an MIT- style license that can be * found in the LICENSE file at https://github.com/nrwl/nx/blob/master/LICENSE */ const path = require("path"); function names(name) { return { name, className: toClassName(name), propertyName: toPropertyName(name), fileName: toFileName(name) }; } exports.names = names; function toClassName(str) { return toCapitalCase(toPropertyName(str)); } exports.toClassName = toClassName; function toPropertyName(s) { return s .replace(/(-|_|\.|\s)+(.)?/g, (_, __, chr) => (chr ? chr.toUpperCase() : '')) .replace(/^([A-Z])/, m => m.toLowerCase()); } exports.toPropertyName = toPropertyName; function toFileName(s) { return s .replace(/([a-z\d])([A-Z])/g, '$1_$2') .toLowerCase() .replace(/[ _]/g, '-'); } exports.toFileName = toFileName; function toCapitalCase(s) { return s.charAt(0).toUpperCase() + s.substr(1); } /** * Determine the parent directory for the ngModule specified * in the full-path option 'module' */ function findModuleParent(modulePath) { return path.dirname(modulePath); } exports.findModuleParent = findModuleParent; //# sourceMappingURL=name-utils.js.map