2017-12-27 16:44:15 -05:00
|
|
|
const log = require('./log');
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
2018-01-28 22:18:14 -05:00
|
|
|
const RESOURCE_DIR = path.resolve(__dirname, "../..");
|
2017-12-27 16:44:15 -05:00
|
|
|
|
2018-11-21 11:19:33 +01:00
|
|
|
// where "trilium" executable is
|
|
|
|
const ELECTRON_APP_ROOT_DIR = path.resolve(RESOURCE_DIR, "../..");
|
2018-01-28 21:00:54 -05:00
|
|
|
const DB_INIT_DIR = path.resolve(RESOURCE_DIR, "db");
|
2017-12-27 16:44:15 -05:00
|
|
|
|
2018-01-28 21:00:54 -05:00
|
|
|
if (!fs.existsSync(DB_INIT_DIR)) {
|
|
|
|
log.error("Could not find DB initialization directory: " + DB_INIT_DIR);
|
2017-12-27 16:44:15 -05:00
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
2018-01-28 21:00:54 -05:00
|
|
|
const MIGRATIONS_DIR = path.resolve(DB_INIT_DIR, "migrations");
|
2017-12-27 16:44:15 -05:00
|
|
|
|
2018-01-28 21:00:54 -05:00
|
|
|
if (!fs.existsSync(MIGRATIONS_DIR)) {
|
|
|
|
log.error("Could not find migration directory: " + MIGRATIONS_DIR);
|
2017-12-27 16:44:15 -05:00
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
RESOURCE_DIR,
|
|
|
|
MIGRATIONS_DIR,
|
2018-11-21 11:01:03 +01:00
|
|
|
DB_INIT_DIR,
|
2019-01-22 19:49:33 +01:00
|
|
|
ELECTRON_APP_ROOT_DIR
|
2017-12-27 16:44:15 -05:00
|
|
|
};
|