Fix error when compiling ormconfig
This commit is contained in:
parent
e760654c54
commit
6b44027eb4
4 changed files with 19 additions and 30 deletions
|
@ -1,38 +1,23 @@
|
|||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const pkgUp = require("pkg-up");
|
||||
|
||||
const closestPackageJson = pkgUp.sync();
|
||||
if (!closestPackageJson) {
|
||||
throw new Error("Could not find project root from ormconfig.js");
|
||||
}
|
||||
const backendRoot = path.dirname(closestPackageJson);
|
||||
|
||||
try {
|
||||
fs.accessSync(path.resolve(backendRoot, "bot.env"));
|
||||
require("dotenv").config({ path: path.resolve(backendRoot, "bot.env") });
|
||||
} catch {
|
||||
try {
|
||||
fs.accessSync(path.resolve(backendRoot, "api.env"));
|
||||
require("dotenv").config({ path: path.resolve(backendRoot, "api.env") });
|
||||
} catch {
|
||||
throw new Error("bot.env or api.env required");
|
||||
}
|
||||
}
|
||||
const { backendDir } = require("./dist/backend/src/paths");
|
||||
const { env } = require("./dist/backend/src/env");
|
||||
|
||||
const moment = require("moment-timezone");
|
||||
moment.tz.setDefault("UTC");
|
||||
|
||||
const entities = path.relative(process.cwd(), path.resolve(backendRoot, "dist/backend/src/data/entities/*.js"));
|
||||
const migrations = path.relative(process.cwd(), path.resolve(backendRoot, "dist/backend/src/migrations/*.js"));
|
||||
const migrationsDir = path.relative(process.cwd(), path.resolve(backendRoot, "src/migrations"));
|
||||
const entities = path.relative(process.cwd(), path.resolve(backendDir, "dist/backend/src/data/entities/*.js"));
|
||||
const migrations = path.relative(process.cwd(), path.resolve(backendDir, "dist/backend/src/migrations/*.js"));
|
||||
const migrationsDir = path.relative(process.cwd(), path.resolve(backendDir, "src/migrations"));
|
||||
|
||||
module.exports = {
|
||||
type: "mysql",
|
||||
host: process.env.DB_HOST,
|
||||
username: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_DATABASE,
|
||||
host: env.DB_HOST,
|
||||
port: env.DB_PORT,
|
||||
username: env.DB_USER,
|
||||
password: env.DB_PASSWORD,
|
||||
database: env.DB_DATABASE,
|
||||
charset: "utf8mb4",
|
||||
supportBigNumbers: true,
|
||||
bigNumberStrings: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue