pear-runtime-updater 0.0.14 → 1.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.
- package/index.js +3 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -9,7 +9,6 @@ const ReadyResource = require('ready-resource')
|
|
|
9
9
|
const link = require('pear-link')
|
|
10
10
|
const hid = require('hypercore-id-encoding')
|
|
11
11
|
const { platform, arch } = require('which-runtime')
|
|
12
|
-
const isMobile = platform === 'ios' || platform === 'android'
|
|
13
12
|
const host = platform + '-' + arch
|
|
14
13
|
|
|
15
14
|
module.exports = class PearRuntime extends ReadyResource {
|
|
@@ -22,7 +21,7 @@ module.exports = class PearRuntime extends ReadyResource {
|
|
|
22
21
|
this.dir = opts.dir
|
|
23
22
|
this.version = opts.version || 0
|
|
24
23
|
this.app = opts.app
|
|
25
|
-
this.name = this.app && path.basename(this.app)
|
|
24
|
+
this.name = opts.name ?? (this.app && path.basename(this.app))
|
|
26
25
|
this.bundled = opts.bundled || !!this.app
|
|
27
26
|
|
|
28
27
|
if (this.updates) {
|
|
@@ -89,9 +88,7 @@ module.exports = class PearRuntime extends ReadyResource {
|
|
|
89
88
|
this.applied = true
|
|
90
89
|
|
|
91
90
|
// mac only for now, linux similar, windows, more pain
|
|
92
|
-
|
|
93
|
-
if (!isMobile) segments.push(this.name)
|
|
94
|
-
await fsx.swap(path.join(...segments), this.app)
|
|
91
|
+
await fsx.swap(path.join(this.next, 'by-arch', host, 'app', this.name), this.app)
|
|
95
92
|
await fs.promises.rm(this.next, { recursive: true, force: true })
|
|
96
93
|
}
|
|
97
94
|
|
|
@@ -121,11 +118,10 @@ module.exports = class PearRuntime extends ReadyResource {
|
|
|
121
118
|
const local = new Localdrive(next)
|
|
122
119
|
|
|
123
120
|
this.emit('updating')
|
|
124
|
-
const prefix = `/by-arch/${host}/app
|
|
121
|
+
const prefix = `/by-arch/${host}/app/${this.name}`
|
|
125
122
|
for await (const data of co.mirror(local, { prefix })) {
|
|
126
123
|
this.emit('updating-delta', data)
|
|
127
124
|
}
|
|
128
|
-
if (isMobile) await local.put(`${prefix}/package.json`, manifest)
|
|
129
125
|
|
|
130
126
|
await co.close()
|
|
131
127
|
await local.close()
|