pear-runtime-updater 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/index.js +4 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -28,6 +28,7 @@ const updater = new PearRuntimeUpdater({
28
28
  upgrade,
29
29
  version,
30
30
  app: getApp() // path to .app / .AppImage
31
+ name: 'name.ext' // <name>.app, <name>.AppImage, <name>.msix
31
32
  })
32
33
 
33
34
  await updater.ready()
@@ -56,6 +57,7 @@ process.on('beforeExit', () => updater.close())
56
57
 
57
58
  - `opts.dir` – (required) Directory to store data (e.g. app data dir).
58
59
  - `opts.upgrade` – (required) Pear upgrade link (e.g. from `package.json` `upgrade` field).
60
+ - `opts.name` – (required) Application name with extension.
59
61
  - `opts.version` – (optional) Current app version; used to decide if an update should be stored.
60
62
  - `opts.app` – (optional) Path to the app bundle (for bundled apps; used with `applyUpdate()`).
61
63
  - `opts.bundled` – (optional) Whether the app is bundled. Defaults to `!!opts.app`.
package/index.js CHANGED
@@ -11,18 +11,18 @@ const hid = require('hypercore-id-encoding')
11
11
  const { platform, arch, isWindows } = require('which-runtime')
12
12
  const host = platform + '-' + arch
13
13
 
14
- module.exports = class PearRuntime extends ReadyResource {
14
+ module.exports = class PearRuntimeUpdater extends ReadyResource {
15
15
  constructor(opts = {}) {
16
16
  super()
17
17
  this.updates = opts.updates !== false
18
18
  if (!opts.dir) throw new Error('dir required')
19
19
  if (!opts.upgrade) throw new Error('upgrade link required')
20
+ if (!opts.name) throw new Error('name required')
20
21
 
21
22
  this.dir = opts.dir
22
23
  this.version = opts.version || 0
23
24
  this.app = opts.app
24
- this.name = opts.name ?? (this.app && path.basename(this.app))
25
- if (isWindows) this.name = path.basename(this.name, path.extname(this.name)) + '.msix'
25
+ this.name = opts.name
26
26
  this.bootstrap = opts.bootstrap
27
27
  this.bundled = opts.bundled || !!this.app
28
28
  this.win32RestartAfterUpdate = opts.win32 && opts.win32.restart
@@ -104,7 +104,7 @@ module.exports = class PearRuntime extends ReadyResource {
104
104
  }
105
105
 
106
106
  _updateBackground() {
107
- this._update().catch(noop)
107
+ this._update().catch((err) => this.emit('error', err))
108
108
  }
109
109
 
110
110
  async _update() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pear-runtime-updater",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "Listens for OTA Pear App updates",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Holepunch Inc",