[Various] Minor general source cleanup
This commit is contained in:
parent
c1b6fc2a97
commit
9bf21e63d1
9 changed files with 18 additions and 18 deletions
|
@ -1,7 +1,7 @@
|
||||||
const { releaseChannel } = require('./utils/buildInfo');
|
const { releaseChannel } = require('./utils/buildInfo');
|
||||||
const settings = require('./appSettings').getSettings();
|
const settings = require('./appSettings').getSettings();
|
||||||
|
|
||||||
const titleCase = (s) => s[0].toUpperCase() + s.slice(1);
|
const titleCase = s => s[0].toUpperCase() + s.slice(1);
|
||||||
|
|
||||||
const appNameSuffix = releaseChannel === 'stable' ? '' : titleCase(releaseChannel);
|
const appNameSuffix = releaseChannel === 'stable' ? '' : titleCase(releaseChannel);
|
||||||
const APP_NAME = 'Discord' + appNameSuffix;
|
const APP_NAME = 'Discord' + appNameSuffix;
|
||||||
|
|
|
@ -21,9 +21,9 @@ module.exports = async () => { // (Try) update asar
|
||||||
const downloadSuccess = await new Promise((res) => {
|
const downloadSuccess = await new Promise((res) => {
|
||||||
const file = fs.createWriteStream(downloadPath);
|
const file = fs.createWriteStream(downloadPath);
|
||||||
|
|
||||||
let writeError = false;
|
let writeError;
|
||||||
file.on('error', err => {
|
file.on('error', e => {
|
||||||
log('AsarUpdate', 'Failed to write', err);
|
log('AsarUpdate', 'Failed to write', e);
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
writeError = true;
|
writeError = true;
|
||||||
|
|
|
@ -9,7 +9,7 @@ module.exports = () => {
|
||||||
|
|
||||||
const installDir = paths.getInstallPath();
|
const installDir = paths.getInstallPath();
|
||||||
|
|
||||||
const nextRes = join(installDir, fs.readdirSync(installDir).reverse().find((x) => x.startsWith('app-1')), 'resources');
|
const nextRes = join(installDir, fs.readdirSync(installDir).reverse().find(x => x.startsWith('app-1')), 'resources');
|
||||||
const next = join(nextRes, 'app.asar');
|
const next = join(nextRes, 'app.asar');
|
||||||
const backup = join(nextRes, 'app.asar.backup');
|
const backup = join(nextRes, 'app.asar.backup');
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Stub (Darwin)
|
// Stub (Darwin)
|
||||||
exports.install = (c) => c();
|
exports.install = c => c();
|
||||||
exports.update = (c) => c();
|
exports.update = c => c();
|
||||||
exports.uninstall = (c) => c();
|
exports.uninstall = c => c();
|
||||||
exports.isInstalled = (c) => c(false);
|
exports.isInstalled = c => c(false);
|
|
@ -32,7 +32,7 @@ const open = exports.open = () => {
|
||||||
settings.save(); // Ensure saving
|
settings.save(); // Ensure saving
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('cg', (e) => {
|
ipcMain.on('cg', e => {
|
||||||
e.returnValue = config;
|
e.returnValue = config;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ const initModuleUpdater = () => { // "Old" (not v2 / new, win32 only)
|
||||||
add('installing-module-progress', progressCallback(installs));
|
add('installing-module-progress', progressCallback(installs));
|
||||||
|
|
||||||
|
|
||||||
add('update-manually', (e) => {
|
add('update-manually', e => {
|
||||||
splashState.newVersion = e.newVersion;
|
splashState.newVersion = e.newVersion;
|
||||||
sendState('update-manually');
|
sendState('update-manually');
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@ const events = require('events');
|
||||||
|
|
||||||
const { get } = require('request');
|
const { get } = require('request');
|
||||||
|
|
||||||
const vParse = (s) => s.split('.').map((x) => parseInt(x));
|
const vParse = s => s.split('.').map(x => parseInt(x));
|
||||||
const vNewer = (a, b) => a.some((x, i) => x === b[i] ? undefined : (x > b[i]));
|
const vNewer = (a, b) => a.some((x, i) => x === b[i] ? undefined : (x > b[i]));
|
||||||
|
|
||||||
class HostLinux extends events.EventEmitter {
|
class HostLinux extends events.EventEmitter {
|
||||||
|
|
|
@ -80,7 +80,7 @@ exports.init = (endpoint, _settings, { releaseChannel, version }) => {
|
||||||
|
|
||||||
hostUpdater.on('update-not-available', hostPassed);
|
hostUpdater.on('update-not-available', hostPassed);
|
||||||
|
|
||||||
hostUpdater.on('update-manually', (v) => {
|
hostUpdater.on('update-manually', v => {
|
||||||
log('Modules', 'Host manual');
|
log('Modules', 'Host manual');
|
||||||
checking = false;
|
checking = false;
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ const installModule = async (name, ver, path) => {
|
||||||
|
|
||||||
let hasError;
|
let hasError;
|
||||||
|
|
||||||
const handleErr = (e) => {
|
const handleErr = e => {
|
||||||
if (hasError) return;
|
if (hasError) return;
|
||||||
hasError = true;
|
hasError = true;
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ const installModule = async (name, ver, path) => {
|
||||||
const total = await new Promise((res) => {
|
const total = await new Promise((res) => {
|
||||||
const p = execFile('unzip', ['-l', path]);
|
const p = execFile('unzip', ['-l', path]);
|
||||||
|
|
||||||
p.stdout.on('data', (x) => {
|
p.stdout.on('data', x => {
|
||||||
const m = x.toString().match(/([0-9]+) files/);
|
const m = x.toString().match(/([0-9]+) files/);
|
||||||
if (m) res(parseInt(m[1]));
|
if (m) res(parseInt(m[1]));
|
||||||
});
|
});
|
||||||
|
@ -300,8 +300,8 @@ const installModule = async (name, ver, path) => {
|
||||||
proc.stderr.on('data', handleErr);
|
proc.stderr.on('data', handleErr);
|
||||||
|
|
||||||
let cur = 0;
|
let cur = 0;
|
||||||
proc.stdout.on('data', (x) => x.toString().split('\n').forEach((x) => {
|
proc.stdout.on('data', x => x.toString().split('\n').forEach(y => {
|
||||||
if (!x.includes('inflating')) return;
|
if (!y.includes('inflating')) return;
|
||||||
|
|
||||||
cur++;
|
cur++;
|
||||||
const progress = Math.min(100, Math.floor(cur / total * 100));
|
const progress = Math.min(100, Math.floor(cur / total * 100));
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
// For Module Updater: get root path for all modules in globalPaths
|
// For Module Updater: get root path for all modules in globalPaths
|
||||||
|
|
||||||
const g = require('module').globalPaths;
|
const g = require('module').globalPaths;
|
||||||
module.exports = (n, e = '') => require(require('path').join(g.find((x) => x.includes(n)) ?? g[0], n, e));
|
module.exports = (n, e = '') => require(require('path').join(g.find(x => x.includes(n)) ?? g[0], n, e));
|
Loading…
Add table
Add a link
Reference in a new issue