(opt: CaseOption | CaseFileOption | undefined, val: string | null, singular = false)
| 206 | |
| 207 | /** Change casing of val string according to opt [c|l|o|p|u] */ |
| 208 | export function recase(opt: CaseOption | CaseFileOption | undefined, val: string | null, singular = false) { |
| 209 | if (singular && val) { |
| 210 | val = singularize(val); |
| 211 | } |
| 212 | if (!opt || opt === 'o' || !val) { |
| 213 | return val || ''; // original |
| 214 | } |
| 215 | if (opt === 'c') { |
| 216 | return _.camelCase(val); |
| 217 | } |
| 218 | if (opt === 'k') { |
| 219 | return _.kebabCase(val); |
| 220 | } |
| 221 | if (opt === 'l') { |
| 222 | return _.snakeCase(val); |
| 223 | } |
| 224 | if (opt === 'p') { |
| 225 | return _.upperFirst(_.camelCase(val)); |
| 226 | } |
| 227 | if (opt === 'u') { |
| 228 | return _.snakeCase(val).toUpperCase(); |
| 229 | } |
| 230 | return val; |
| 231 | } |
| 232 | |
| 233 | const tsNames = ["DataTypes", "Model", "Optional", "Sequelize"]; |
| 234 | export function makeTableName(opt: CaseOption | undefined, tableNameOrig: string | null, singular = false, lang = "es5") { |
no test coverage detected