-
Notifications
You must be signed in to change notification settings - Fork 0
/
ormconfig.js
32 lines (28 loc) · 888 Bytes
/
ormconfig.js
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
// An attempt to deal with difficulties of dynamically importing `src` vs. `lib`
// from typescript. Keep everything in typescript under src, where relative
// paths can easily refer to other typescript files. And at the top level, use
// this .js module to dynamically figure out where to load from.
// Based on https://github.com/nodejs/node/issues/1381
// “Module API to check if a module has been loaded”
function moduleLoaded(name) {
let path;
try {
path = require.resolve(name);
} catch (e) {
if (e.code === "MODULE_NOT_FOUND") {
return false;
}
throw e;
}
return !!require.cache[path];
}
// If running with babel-register, read ormconfig.ts from src dir. Otherwise
// use lib dir.
let dir;
if (moduleLoaded("@babel/register")) {
dir = "src";
} else {
dir = "lib";
}
const config = require(`./${dir}/ormconfig`);
module.exports = config;