pear-runtime-updater 3.0.6 → 3.0.7
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.
- package/index.js +8 -10
- package/package.json +2 -1
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const link = require('pear-link')
|
|
|
8
8
|
const hid = require('hypercore-id-encoding')
|
|
9
9
|
const { platform, arch, isWindows } = require('which-runtime')
|
|
10
10
|
const semver = require('bare-semver')
|
|
11
|
+
const debounceify = require('debounceify')
|
|
11
12
|
const host = platform + '-' + arch
|
|
12
13
|
|
|
13
14
|
module.exports = class PearRuntimeUpdater extends ReadyResource {
|
|
@@ -39,6 +40,8 @@ module.exports = class PearRuntimeUpdater extends ReadyResource {
|
|
|
39
40
|
this.updating = false
|
|
40
41
|
this.updated = false
|
|
41
42
|
|
|
43
|
+
this._debouncedUpdate = debounceify(this._update.bind(this))
|
|
44
|
+
|
|
42
45
|
this.ready().catch(noop)
|
|
43
46
|
}
|
|
44
47
|
|
|
@@ -52,8 +55,10 @@ module.exports = class PearRuntimeUpdater extends ReadyResource {
|
|
|
52
55
|
force: true
|
|
53
56
|
})
|
|
54
57
|
|
|
55
|
-
this.
|
|
56
|
-
this.drive.core.on('append', () =>
|
|
58
|
+
this._debouncedUpdate().catch((err) => this.emit('error', err))
|
|
59
|
+
this.drive.core.on('append', () =>
|
|
60
|
+
this._debouncedUpdate().catch((err) => this.emit('error', err))
|
|
61
|
+
)
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
64
|
|
|
@@ -79,12 +84,8 @@ module.exports = class PearRuntimeUpdater extends ReadyResource {
|
|
|
79
84
|
await fs.promises.rm(this.next, { recursive: true, force: true })
|
|
80
85
|
}
|
|
81
86
|
|
|
82
|
-
_updateBackground() {
|
|
83
|
-
this._update().catch((err) => this.emit('error', err))
|
|
84
|
-
}
|
|
85
|
-
|
|
86
87
|
async _update() {
|
|
87
|
-
if (
|
|
88
|
+
if (!this.updates) return
|
|
88
89
|
|
|
89
90
|
await this.drive.update()
|
|
90
91
|
|
|
@@ -111,7 +112,6 @@ module.exports = class PearRuntimeUpdater extends ReadyResource {
|
|
|
111
112
|
if (!remote || current.compare(remote) >= 0) {
|
|
112
113
|
this.checkout = null
|
|
113
114
|
await co.close()
|
|
114
|
-
if (this.drive.core.length > length) this._updateBackground()
|
|
115
115
|
return
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -136,8 +136,6 @@ module.exports = class PearRuntimeUpdater extends ReadyResource {
|
|
|
136
136
|
this.updating = false
|
|
137
137
|
this.updated = true
|
|
138
138
|
this.emit('updated')
|
|
139
|
-
|
|
140
|
-
if (this.drive.core.length > length) this._updateBackground()
|
|
141
139
|
}
|
|
142
140
|
|
|
143
141
|
async _prefetchLatest() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pear-runtime-updater",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7",
|
|
4
4
|
"description": "Listens for OTA Pear App updates",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Holepunch Inc",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"bare-fs": "^4.5.3",
|
|
47
47
|
"bare-path": "^3.0.0",
|
|
48
48
|
"bare-semver": "^1.0.2",
|
|
49
|
+
"debounceify": "^1.1.0",
|
|
49
50
|
"fs-native-extensions": "^1.4.5",
|
|
50
51
|
"hypercore-id-encoding": "^1.3.0",
|
|
51
52
|
"hyperdrive": "^13.2.1",
|