2017-12-28 05:44:15 +08:00
|
|
|
const log = require('./log');
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const RESOURCE_DIR = path.resolve(__dirname, "..");
|
|
|
|
|
2018-01-29 10:00:54 +08:00
|
|
|
const DB_INIT_DIR = path.resolve(RESOURCE_DIR, "db");
|
2017-12-28 05:44:15 +08:00
|
|
|
|
2018-01-29 10:00:54 +08:00
|
|
|
if (!fs.existsSync(DB_INIT_DIR)) {
|
|
|
|
log.error("Could not find DB initialization directory: " + DB_INIT_DIR);
|
2017-12-28 05:44:15 +08:00
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
2018-01-29 10:00:54 +08:00
|
|
|
const MIGRATIONS_DIR = path.resolve(DB_INIT_DIR, "migrations");
|
2017-12-28 05:44:15 +08:00
|
|
|
|
2018-01-29 10:00:54 +08:00
|
|
|
if (!fs.existsSync(MIGRATIONS_DIR)) {
|
|
|
|
log.error("Could not find migration directory: " + MIGRATIONS_DIR);
|
2017-12-28 05:44:15 +08:00
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
RESOURCE_DIR,
|
|
|
|
MIGRATIONS_DIR,
|
|
|
|
DB_INIT_DIR
|
|
|
|
};
|