-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathconsole.ts
41 lines (36 loc) · 892 Bytes
/
console.ts
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
41
/*
* youch
*
* (c) Poppinss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { createError } from '@poppinss/exception'
import { run as pg } from './pg.js'
import { Youch } from '../src/youch.js'
import { run as axios } from './axios.js'
import { run as drive } from './flydrive.js'
const argv = process.argv.splice(2)
const fn = argv[0] ?? 'axios'
const E_COMMAND_NOT_FOUND = createError('Command not found', 'E_COMMAND_NOT_FOUND', 404)
try {
switch (fn) {
case 'axios':
await axios()
break
case 'drive':
await drive()
break
case 'pg':
await pg()
break
default:
throw new E_COMMAND_NOT_FOUND()
}
} catch (error) {
const youch = new Youch()
const output = await youch.toANSI(error)
console.error(output)
process.exit(1)
}