pear-build 0.1.1 → 0.2.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 (2) hide show
  1. package/index.js +8 -20
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -45,39 +45,27 @@ module.exports = async function build(dir, opts = {}) {
45
45
  androidArm64
46
46
  ].filter(Boolean)
47
47
 
48
+ const appName = pkg.productName ?? pkg.name
49
+
48
50
  const noop = () => {}
49
51
  const promises = []
50
52
  for (const [arch, app] of apps) {
51
- const isMobile = arch.startsWith('ios') || arch.startsWith('android')
52
- const appName = isMobile ? (pkg.productName ?? pkg.name) : path.basename(app)
53
- if (typeof appName !== 'string') {
54
- throw new Error('package.json productName or name is a required field string')
53
+ if (path.basename(app, path.extname(app)) !== appName) {
54
+ throw new Error(`expected directory ${appName} but got ${path.basename(app)} for ${arch}`)
55
55
  }
56
56
  const archApp = path.join(byArch, arch, 'app')
57
57
  await fs.promises.mkdir(archApp, { recursive: true })
58
58
 
59
- const stat = await fs.promises.stat(app)
60
- let src, dst, mirror
61
- if (stat.isDirectory()) {
62
- const appDir = path.join(archApp, appName)
63
- await fs.promises.mkdir(appDir, { recursive: true })
64
- src = new Localdrive(app)
65
- dst = new Localdrive(appDir)
66
- mirror = src.mirror(dst)
67
- } else {
68
- src = new Localdrive(path.dirname(app))
69
- dst = new Localdrive(archApp)
70
- mirror = src.mirror(dst, { prefix: '/' + path.basename(app) })
71
- }
59
+ const src = new Localdrive(path.dirname(app))
60
+ const dst = new Localdrive(archApp)
61
+ const mirror = src.mirror(dst, { prefix: '/' + path.basename(app) })
72
62
 
73
63
  await src.ready()
74
64
  await dst.ready()
75
65
  console.log(app, 'mirroring to', archApp)
76
66
  const promise = mirror.done()
77
67
  promises.push(promise)
78
- promise.then(() => {
79
- console.log(app, 'mirrored to', archApp)
80
- }, noop)
68
+ promise.then(() => console.log(app, 'mirrored to', archApp), noop)
81
69
  await src.close()
82
70
  await dst.close()
83
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pear-build",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "main": "index.js",
5
5
  "type": "commonjs",
6
6
  "bin": "bin.js",