pear-runtime-updater 0.0.7 → 0.0.9

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 (2) hide show
  1. package/index.js +9 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -9,7 +9,8 @@ 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 host = platform + '-' + arch
12
+ const isMobile = platform === 'ios' || platform === 'android'
13
+ const host = isMobile ? platform : platform + '-' + arch
13
14
 
14
15
  module.exports = class PearRuntime extends ReadyResource {
15
16
  constructor(opts = {}) {
@@ -51,9 +52,10 @@ module.exports = class PearRuntime extends ReadyResource {
51
52
  }
52
53
 
53
54
  async _open() {
55
+ if (!this.updates) return
54
56
  await this.drive.ready()
55
57
 
56
- if (this.bundled && this.updates !== false) {
58
+ if (this.bundled) {
57
59
  await fs.promises.rm(path.join(this.dir, 'pear-runtime/next'), {
58
60
  recursive: true,
59
61
  force: true
@@ -87,7 +89,9 @@ module.exports = class PearRuntime extends ReadyResource {
87
89
  this.applied = true
88
90
 
89
91
  // mac only for now, linux similar, windows, more pain
90
- await fsx.swap(path.join(this.next, 'by-arch', host, 'app', this.name), this.app)
92
+ const segments = [this.next, 'by-arch', host, 'app']
93
+ if (!isMobile) segments.push(this.name)
94
+ await fsx.swap(path.join(...segments), this.app)
91
95
  await fs.promises.rm(this.next, { recursive: true, force: true })
92
96
  }
93
97
 
@@ -96,7 +100,7 @@ module.exports = class PearRuntime extends ReadyResource {
96
100
  }
97
101
 
98
102
  async _update() {
99
- if (this.updating || this.updates === false) return
103
+ if (this.updating || !this.updates) return
100
104
  this.updating = true
101
105
 
102
106
  const length = this.drive.core.length
@@ -117,7 +121,7 @@ module.exports = class PearRuntime extends ReadyResource {
117
121
  const local = new Localdrive(next)
118
122
 
119
123
  this.emit('updating')
120
- const prefix = '/by-arch/' + host + '/app/' + this.name
124
+ const prefix = `/by-arch/${host}/app/${isMobile ? '' : this.name}`
121
125
  for await (const data of co.mirror(local, { prefix })) {
122
126
  this.emit('updating-delta', data)
123
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pear-runtime-updater",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Listens for OTA Pear App updates",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Holepunch Inc",