[Various] Minor general source cleanup

This commit is contained in:
Ducko 2022-04-04 15:41:49 +01:00
parent c1b6fc2a97
commit 9bf21e63d1
9 changed files with 18 additions and 18 deletions

View file

@ -1,7 +1,7 @@
const { releaseChannel } = require('./utils/buildInfo');
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 APP_NAME = 'Discord' + appNameSuffix;

View file

@ -21,9 +21,9 @@ module.exports = async () => { // (Try) update asar
const downloadSuccess = await new Promise((res) => {
const file = fs.createWriteStream(downloadPath);
let writeError = false;
file.on('error', err => {
log('AsarUpdate', 'Failed to write', err);
let writeError;
file.on('error', e => {
log('AsarUpdate', 'Failed to write', e);
file.close();
writeError = true;

View file

@ -9,7 +9,7 @@ module.exports = () => {
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 backup = join(nextRes, 'app.asar.backup');

View file

@ -1,5 +1,5 @@
// Stub (Darwin)
exports.install = (c) => c();
exports.update = (c) => c();
exports.uninstall = (c) => c();
exports.isInstalled = (c) => c(false);
exports.install = c => c();
exports.update = c => c();
exports.uninstall = c => c();
exports.isInstalled = c => c(false);

View file

@ -32,7 +32,7 @@ const open = exports.open = () => {
settings.save(); // Ensure saving
});
ipcMain.on('cg', (e) => {
ipcMain.on('cg', e => {
e.returnValue = config;
});

View file

@ -277,7 +277,7 @@ const initModuleUpdater = () => { // "Old" (not v2 / new, win32 only)
add('installing-module-progress', progressCallback(installs));
add('update-manually', (e) => {
add('update-manually', e => {
splashState.newVersion = e.newVersion;
sendState('update-manually');
});

View file

@ -3,7 +3,7 @@ const events = require('events');
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]));
class HostLinux extends events.EventEmitter {

View file

@ -80,7 +80,7 @@ exports.init = (endpoint, _settings, { releaseChannel, version }) => {
hostUpdater.on('update-not-available', hostPassed);
hostUpdater.on('update-manually', (v) => {
hostUpdater.on('update-manually', v => {
log('Modules', 'Host manual');
checking = false;
@ -260,7 +260,7 @@ const installModule = async (name, ver, path) => {
let hasError;
const handleErr = (e) => {
const handleErr = e => {
if (hasError) return;
hasError = true;
@ -276,7 +276,7 @@ const installModule = async (name, ver, path) => {
const total = await new Promise((res) => {
const p = execFile('unzip', ['-l', path]);
p.stdout.on('data', (x) => {
p.stdout.on('data', x => {
const m = x.toString().match(/([0-9]+) files/);
if (m) res(parseInt(m[1]));
});
@ -300,8 +300,8 @@ const installModule = async (name, ver, path) => {
proc.stderr.on('data', handleErr);
let cur = 0;
proc.stdout.on('data', (x) => x.toString().split('\n').forEach((x) => {
if (!x.includes('inflating')) return;
proc.stdout.on('data', x => x.toString().split('\n').forEach(y => {
if (!y.includes('inflating')) return;
cur++;
const progress = Math.min(100, Math.floor(cur / total * 100));

View file

@ -3,4 +3,4 @@
// For Module Updater: get root path for all modules in 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));