electron-updater
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -253,5 +253,13 @@ "use strict"; | ||
} | ||
return yield _this3.doDownloadUpdate(versionInfo, fileInfo); | ||
try { | ||
return yield _this3.doDownloadUpdate(versionInfo, fileInfo); | ||
} catch (e) { | ||
_this3.dispatchError(e); | ||
throw e; | ||
} | ||
})(); | ||
} | ||
dispatchError(e) { | ||
this.emit("error", e, (e.stack || e).toString()); | ||
} | ||
} | ||
@@ -258,0 +266,0 @@ exports.AppUpdater = AppUpdater; |
@@ -134,2 +134,3 @@ declare module "electron-updater/out/api" { | ||
downloadUpdate(): Promise<any> | ||
protected dispatchError(e: Error): void | ||
protected abstract doDownloadUpdate(versionInfo: VersionInfo, fileInfo: FileInfo): Promise<any> | ||
@@ -136,0 +137,0 @@ abstract quitAndInstall(): void |
@@ -81,19 +81,21 @@ "use strict"; | ||
} | ||
return (0, (_fsExtraP || _load_fsExtraP()).mkdtemp)(`${_path.join((0, (_os || _load_os()).tmpdir)(), "up")}-`).then(function (it) { | ||
return (0, (_electronBuilderHttp || _load_electronBuilderHttp()).download)(fileInfo.url, _path.join(it, fileInfo.name), downloadOptions); | ||
}).then(function (it) { | ||
_this.setupPath = it; | ||
_this.addQuitHandler(); | ||
const version = _this.versionInfo.version; | ||
if (_this.logger != null) { | ||
_this.logger.info(`New version ${version} has been downloaded`); | ||
} | ||
_this.emit("update-downloaded", _this.versionInfo, null, version, null, null, function () { | ||
_this.quitAndInstall(); | ||
}); | ||
return it; | ||
}).catch(function (e) { | ||
_this.emit("error", e, (e.stack || e).toString()); | ||
const logger = _this.logger; | ||
const tempDir = yield (0, (_fsExtraP || _load_fsExtraP()).mkdtemp)(`${_path.join((0, (_os || _load_os()).tmpdir)(), "up")}-`); | ||
const tempFile = _path.join(tempDir, fileInfo.name); | ||
try { | ||
yield (0, (_electronBuilderHttp || _load_electronBuilderHttp()).download)(fileInfo.url, tempFile, downloadOptions); | ||
} catch (e) { | ||
try { | ||
yield (0, (_fsExtraP || _load_fsExtraP()).remove)(tempDir); | ||
} catch (ignored) {} | ||
throw e; | ||
}); | ||
} | ||
const version = _this.versionInfo.version; | ||
if (logger != null) { | ||
logger.info(`New version ${version} has been downloaded to ${tempFile}`); | ||
} | ||
_this.setupPath = tempFile; | ||
_this.addQuitHandler(); | ||
_this.emit("update-downloaded", _this.versionInfo, null, version); | ||
return tempFile; | ||
})(); | ||
@@ -107,2 +109,5 @@ } | ||
this.app.on("quit", () => { | ||
if (this.logger != null) { | ||
this.logger.info("Auto install update on quit"); | ||
} | ||
this.install(true); | ||
@@ -132,6 +137,24 @@ }); | ||
} | ||
(0, (_child_process || _load_child_process()).spawn)(setupPath, args, { | ||
const spawnOptions = { | ||
detached: true, | ||
stdio: "ignore" | ||
}).unref(); | ||
}; | ||
try { | ||
(0, (_child_process || _load_child_process()).spawn)(setupPath, args, spawnOptions).unref(); | ||
} catch (e) { | ||
// yes, such errors dispatched not as error event | ||
// https://github.com/electron-userland/electron-builder/issues/1129 | ||
if (e.code === "UNKNOWN") { | ||
if (this.logger != null) { | ||
this.logger.info("UNKNOWN error code on spawn, will be executed again using elevate"); | ||
} | ||
try { | ||
(0, (_child_process || _load_child_process()).spawn)(_path.join(process.resourcesPath, "elevate.exe"), [setupPath].concat(args), spawnOptions).unref(); | ||
} catch (e) { | ||
this.dispatchError(e); | ||
} | ||
} else { | ||
this.dispatchError(e); | ||
} | ||
} | ||
return true; | ||
@@ -138,0 +161,0 @@ } |
{ | ||
"name": "electron-updater", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "NSIS Auto Updater", | ||
@@ -5,0 +5,0 @@ "main": "out/main.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100249
1134