Skip to content

Commit

Permalink
fix(updater): Support Electron 11 and below (Node < 14) (#6594)
Browse files Browse the repository at this point in the history
* Replacing fs/promises with fs-extra to support legacy versions of electron that use node 12 and below.
Fixes: #6000
  • Loading branch information
mmaietta committed Jan 31, 2022
1 parent 5166ddd commit edc4b03
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-foxes-carry.md
@@ -0,0 +1,5 @@
---
"electron-updater": patch
---

fix(updater): Replacing fs/promises with fs-extra to support legacy versions of Electron that use node 12 and below. Fixes: #6000
2 changes: 1 addition & 1 deletion docs/configuration/configuration.md
Expand Up @@ -39,7 +39,7 @@ Env file `electron-builder.env` in the current dir ([example](https://github.com
<!-- do not edit. start of generated block -->
<ul>
<li><code id="Configuration-appId">appId</code> = <code>com.electron.${name}</code> String | “undefined” - The application id. Used as <a href="https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070">CFBundleIdentifier</a> for MacOS and as <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx">Application User Model ID</a> for Windows (NSIS target only, Squirrel.Windows not supported). It is strongly recommended that an explicit ID is set.</li>
<li><code id="Configuration-productName">productName</code> String | “undefined” - As <a href="#Metadata-name">name</a>, but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the <a href="https://docs.npmjs.com/files/package.json#name">name property</a>.</li>
<li><code id="Configuration-productName">productName</code> String | “undefined” - As <a href="#Metadata-name">name</a>, but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the <a href="https://docs.npmjs.com/files/package.json#name">name property</a>. If not specified inside of the <code>build</code> configuration, <code>productName</code> property defined at the top level of <code>package.json</code> is used. If not specified at the top level of <code>package.json</code>, <a href="https://docs.npmjs.com/files/package.json#name">name property</a> is used.</li>
<li><code id="Configuration-copyright">copyright</code> = <code>Copyright © year ${author}</code> String | “undefined” - The human-readable copyright line for the app.</li>
</ul>
<hr>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -73,7 +73,7 @@
"v8-compile-cache": "2.3.0"
},
"engines": {
"node": ">=14",
"node": ">=14.14",
"pnpm": ">=6"
}
}
2 changes: 1 addition & 1 deletion packages/app-builder-lib/scheme.json
Expand Up @@ -6713,7 +6713,7 @@
]
},
"productName": {
"description": "As [name](#Metadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name).",
"description": "As [name](#Metadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name).\nIf not specified inside of the `build` configuration, `productName` property defined at the top level of `package.json` is used. If not specified at the top level of `package.json`, [name property](https://docs.npmjs.com/files/package.json#name) is used.",
"type": [
"null",
"string"
Expand Down
1 change: 1 addition & 0 deletions packages/app-builder-lib/src/configuration.ts
Expand Up @@ -30,6 +30,7 @@ export interface Configuration extends PlatformSpecificBuildOptions {

/**
* As [name](#Metadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name).
* If not specified inside of the `build` configuration, `productName` property defined at the top level of `package.json` is used. If not specified at the top level of `package.json`, [name property](https://docs.npmjs.com/files/package.json#name) is used.
*/
readonly productName?: string | null

Expand Down
9 changes: 4 additions & 5 deletions packages/electron-updater/src/AppUpdater.ts
@@ -1,8 +1,7 @@
import { AllPublishOptions, asArray, CancellationToken, newError, PublishConfiguration, UpdateInfo, UUID, DownloadOptions, CancellationError } from "builder-util-runtime"
import { randomBytes } from "crypto"
import { EventEmitter } from "events"
import { outputFile } from "fs-extra"
import { mkdir, readFile, rename, unlink } from "fs/promises"
import { mkdir, outputFile, readFile, rename, unlink } from "fs-extra"
import { OutgoingHttpHeaders } from "http"
import { load } from "js-yaml"
import { Lazy } from "lazy-val"
Expand Down Expand Up @@ -441,7 +440,7 @@ export abstract class AppUpdater extends EventEmitter {
if (!(e instanceof CancellationError)) {
try {
this.dispatchError(e)
} catch (nestedError) {
} catch (nestedError: any) {
this._logger.warn(`Cannot dispatch error event: ${nestedError.stack || nestedError}`)
}
}
Expand All @@ -458,7 +457,7 @@ export abstract class AppUpdater extends EventEmitter {
}).catch(e => {
throw errorHandler(e)
})
} catch (e) {
} catch (e: any) {
return Promise.reject(errorHandler(e))
}
}
Expand Down Expand Up @@ -515,7 +514,7 @@ export abstract class AppUpdater extends EventEmitter {
} else {
this._logger.warn(`Staging user id file exists, but content was invalid: ${id}`)
}
} catch (e) {
} catch (e: any) {
if (e.code !== "ENOENT") {
this._logger.warn(`Couldn't read staging user ID, creating a blank one: ${e}`)
}
Expand Down

0 comments on commit edc4b03

Please sign in to comment.