|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
const { join, dirname, basename } = require('path');
|
|
|
|
|
const fs = require('fs');
|
|
|
|
|
const { app } = require('electron');
|
|
|
|
|
|
|
|
|
|
const buildInfo = require('./utils/buildInfo');
|
|
|
|
@ -12,7 +13,7 @@ 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');
|
|
|
|
|
const resourcesPath = join(process.resourcesPath); // Discord uses path and require.main.filename here because ??
|
|
|
|
|
const resourcesPath = join(process.resourcesPath);
|
|
|
|
|
|
|
|
|
|
exports.getUserData = () => userData;
|
|
|
|
|
exports.getUserDataVersioned = () => userDataVersioned;
|
|
|
|
@ -21,6 +22,18 @@ exports.getResources = () => resourcesPath;
|
|
|
|
|
exports.getModuleDataPath = () => moduleData;
|
|
|
|
|
exports.getInstallPath = () => installPath;
|
|
|
|
|
|
|
|
|
|
exports.getExeDir = () => exeDir; // Custom / non-standard
|
|
|
|
|
exports.getExeDir = () => exeDir;
|
|
|
|
|
|
|
|
|
|
exports.init = () => {}; // Stub as we setup on require
|
|
|
|
|
exports.init = () => {}; // Stub as we setup on require
|
|
|
|
|
|
|
|
|
|
exports.cleanOldVersions = () => {
|
|
|
|
|
if (!installPath) return;
|
|
|
|
|
log('Paths', 'Cleaning old app dirs...');
|
|
|
|
|
|
|
|
|
|
for (const x of fs.readdirSync(installPath)) {
|
|
|
|
|
if (x.startsWith('app-') && !x.includes(buildInfo.version)) {
|
|
|
|
|
log('Paths', 'Removing', x);
|
|
|
|
|
fs.rmSync(join(installPath, x), { recursive: true, force: true });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|