UNPKG

@nestjs/cli

Version:

The Nest CLI: create NestJS applications, generate modules, controllers and CRUD resources, and build, run and watch projects and monorepos.

16 lines (15 loc) • 511 B
/** * * @param str * @returns formated string * @description normalizes input to supported path and file name format. * Changes camelCase strings to kebab-case, replaces spaces with dash and keeps underscores. */ export function normalizeToKebabOrSnakeCase(str) { const STRING_DASHERIZE_REGEXP = /\s/g; const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g; return str .replace(STRING_DECAMELIZE_REGEXP, '$1-$2') .toLowerCase() .replace(STRING_DASHERIZE_REGEXP, '-'); }