-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutils.ts
27 lines (21 loc) · 894 Bytes
/
utils.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
import 'reflect-metadata'
import { Application } from '@Typetron/Framework'
import * as path from 'path'
export function prepareApp() {
const tsConfig = require(path.join(process.cwd(), 'tsconfig'))
const tsConfigPaths = require('tsconfig-paths')
// TODO this package tries to load a ton of files until it finds the right one
// Need more investigation on this as it slows down the CLI app quite a bit
tsConfigPaths.register({
baseUrl: './',
mainFields: ['index'],
paths: tsConfig.compilerOptions.paths
})
}
export async function boostrapApp() {
prepareApp()
const dotenv = require(path.join(process.cwd(), 'node_modules', 'dotenv'))
dotenv.config({path: path.join(process.cwd(), '.env')})
const {appBuilder} = require(path.join(process.cwd(), 'app.ts')) as {appBuilder: Promise<Application>}
return await appBuilder
}