forked from rmp135/sql-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSharedTasks.ts
More file actions
40 lines (38 loc) · 1001 Bytes
/
Copy pathSharedTasks.ts
File metadata and controls
40 lines (38 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { camelCase, pascalCase } from 'change-case'
/**
* Converts the casing of a string.
*
* @export
* @param {string} name The name to convert.
* @param {string} caseType The case type to convert into.
* @returns The converted name.
*/
export function convertCase(name: string, caseType: string) {
switch (caseType) {
case 'pascal':
return pascalCase(name, { mergeAmbiguousCharacters: true })
case 'camel':
return camelCase(name, { mergeAmbiguousCharacters: true })
case 'lower':
return name.toLowerCase()
case 'upper':
return name.toUpperCase()
default:
return name
}
}
/**
* Resolves a common adapter name from an alias.
*
* @param dialect The ambiguous adapter name.
* @returns The resolved dialect name.
*/
export function resolveAdapterName(dialect: string) {
const aliases = {
'postgresql' : 'postgres',
'pg' : 'postgres',
'sqlite3' : 'sqlite',
'mysql2': 'mysql'
}
return aliases[dialect] ?? dialect
}