pear-build 0.1.0 → 0.1.1

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 +20 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -28,7 +28,10 @@ module.exports = async function build(dir, opts = {}) {
28
28
 
29
29
  await fs.promises.mkdir(byArch, { recursive: true })
30
30
 
31
- fs.writeFileSync(path.join(target, 'package.json'), fs.readFileSync(pkgPath))
31
+ await fs.promises.writeFile(
32
+ path.join(target, 'package.json'),
33
+ await fs.promises.readFile(pkgPath)
34
+ )
32
35
 
33
36
  const apps = [
34
37
  darwinArm64App,
@@ -50,13 +53,25 @@ module.exports = async function build(dir, opts = {}) {
50
53
  if (typeof appName !== 'string') {
51
54
  throw new Error('package.json productName or name is a required field string')
52
55
  }
53
- const archApp = path.join(byArch, arch, 'app', appName)
56
+ const archApp = path.join(byArch, arch, 'app')
54
57
  await fs.promises.mkdir(archApp, { recursive: true })
55
- const src = new Localdrive(app)
56
- const dst = new Localdrive(archApp)
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
+ }
72
+
57
73
  await src.ready()
58
74
  await dst.ready()
59
- const mirror = src.mirror(dst)
60
75
  console.log(app, 'mirroring to', archApp)
61
76
  const promise = mirror.done()
62
77
  promises.push(promise)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pear-build",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "main": "index.js",
5
5
  "type": "commonjs",
6
6
  "bin": "bin.js",