2021-12-09 16:25:14 +00:00
|
|
|
const { join, dirname, basename } = require('path');
|
|
|
|
const { app } = require('electron');
|
|
|
|
|
|
|
|
const buildInfo = require('./utils/buildInfo');
|
|
|
|
|
|
|
|
|
|
|
|
const appDir = 'discord' + (buildInfo.releaseChannel === 'stable' ? '' : buildInfo.releaseChannel); // Clean channel naming up later to util?
|
|
|
|
const userData = join(app.getPath('appData'), appDir);
|
|
|
|
const userDataVersioned = join(userData, buildInfo.version);
|
|
|
|
|
|
|
|
const exeDir = dirname(app.getPath('exe'));
|
|
|
|
const installPath = /^app-[0-9]+\.[0-9]+\.[0-9]+/.test(basename(exeDir)) ? join(exeDir, '..') : null;
|
|
|
|
|
|
|
|
const moduleData = buildInfo.newUpdater ? join(userData, 'module_data') : join(userDataVersioned, 'modules');
|
2021-12-12 17:42:43 +00:00
|
|
|
const resourcesPath = join(process.resourcesPath); // Discord uses path and require.main.filename here because ??
|
2021-12-09 16:25:14 +00:00
|
|
|
|
|
|
|
exports.getUserData = () => userData;
|
|
|
|
exports.getUserDataVersioned = () => userDataVersioned;
|
|
|
|
|
2021-12-10 17:17:00 +00:00
|
|
|
exports.getResources = () => resourcesPath;
|
2021-12-09 16:25:14 +00:00
|
|
|
exports.getModuleDataPath = () => moduleData;
|
|
|
|
exports.getInstallPath = () => installPath;
|
|
|
|
|
2021-12-11 15:19:04 +00:00
|
|
|
exports.getExeDir = () => exeDir; // Custom / non-standard
|
|
|
|
|
2021-12-09 16:25:14 +00:00
|
|
|
exports.init = () => {}; // Stub as we setup on require
|