[Updater > v2] Minor source cleanup further
This commit is contained in:
parent
b6947d6729
commit
97ab2297ff
1 changed files with 7 additions and 18 deletions
|
@ -47,7 +47,7 @@ class Updater extends require('events').EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
_sendRequest(detail, progressCallback = null) {
|
_sendRequest(detail, progressCallback = null) {
|
||||||
if (!this.valid) throw new Error('Native fail');
|
if (!this.valid) throw 'No native';
|
||||||
|
|
||||||
const requestId = this.nextRequestId++;
|
const requestId = this.nextRequestId++;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
@ -62,7 +62,7 @@ class Updater extends require('events').EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
_sendRequestSync(detail) {
|
_sendRequestSync(detail) {
|
||||||
if (!this.valid) throw new Error('Native fail');
|
if (!this.valid) throw 'No native';
|
||||||
|
|
||||||
return this.nativeUpdater.command_blocking(JSON.stringify([ this.nextRequestId++, detail ]));
|
return this.nativeUpdater.command_blocking(JSON.stringify([ this.nextRequestId++, detail ]));
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ class Updater extends require('events').EventEmitter {
|
||||||
_handleSyncResponse(response) {
|
_handleSyncResponse(response) {
|
||||||
const detail = JSON.parse(response);
|
const detail = JSON.parse(response);
|
||||||
|
|
||||||
if (detail.Error != null) throw new Error(detail.Error);
|
if (detail.Error != null) throw detail.Error;
|
||||||
else if (detail === 'Ok') return;
|
else if (detail === 'Ok') return;
|
||||||
else if (detail.VersionInfo != null) return detail.VersionInfo;
|
else if (detail.VersionInfo != null) return detail.VersionInfo;
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ class Updater extends require('events').EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
async commitModules(versions) {
|
async commitModules(versions) {
|
||||||
if (this.committedHostVersion == null) throw new Error('Cannot commit modules before host version.');
|
if (this.committedHostVersion == null) throw 'No host';
|
||||||
|
|
||||||
this._commitModulesInner(versions ?? await this.queryCurrentVersions());
|
this._commitModulesInner(versions ?? await this.queryCurrentVersions());
|
||||||
}
|
}
|
||||||
|
@ -301,13 +301,13 @@ class Updater extends require('events').EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
getKnownFolder(name) {
|
getKnownFolder(name) {
|
||||||
if (!this.valid) throw new Error('Native fail');
|
if (!this.valid) throw 'No native';
|
||||||
|
|
||||||
return this.nativeUpdater.known_folder(name);
|
return this.nativeUpdater.known_folder(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
createShortcut(options) {
|
createShortcut(options) {
|
||||||
if (!this.valid) throw new Error('Native fail');
|
if (!this.valid) throw 'No native';
|
||||||
|
|
||||||
return this.nativeUpdater.create_shortcut(options);
|
return this.nativeUpdater.create_shortcut(options);
|
||||||
}
|
}
|
||||||
|
@ -328,20 +328,9 @@ module.exports = {
|
||||||
const root_path = paths.getInstallPath();
|
const root_path = paths.getInstallPath();
|
||||||
if (root_path == null) return false;
|
if (root_path == null) return false;
|
||||||
|
|
||||||
let platform = process.platform;
|
|
||||||
switch (platform) {
|
|
||||||
case 'darwin':
|
|
||||||
platform = 'osx';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'win32':
|
|
||||||
platform = 'win';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
instance = new Updater({
|
instance = new Updater({
|
||||||
release_channel: buildInfo.releaseChannel,
|
release_channel: buildInfo.releaseChannel,
|
||||||
platform,
|
platform: process.platform === 'win32' ? 'win' : 'osx',
|
||||||
repository_url,
|
repository_url,
|
||||||
root_path
|
root_path
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue