bare-runtime 1.0.6 → 1.0.8

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 (3) hide show
  1. package/index.js +34 -0
  2. package/lib/spawn.js +3 -27
  3. package/package.json +17 -12
package/index.js ADDED
@@ -0,0 +1,34 @@
1
+ const path = require('path')
2
+
3
+ module.exports = function runtime (referrer, opts) {
4
+ if (typeof referrer === 'object' && referrer !== null) {
5
+ opts = referrer
6
+ referrer = 'bare'
7
+ } else if (typeof referrer !== 'string') {
8
+ referrer = 'bare'
9
+ }
10
+
11
+ if (!opts) opts = {}
12
+
13
+ const {
14
+ platform = process.platform,
15
+ arch = process.arch
16
+ } = opts
17
+
18
+ const filename = path.basename(referrer)
19
+
20
+ const base = `bare-runtime-${platform}-${arch}`
21
+
22
+ let mod
23
+ try {
24
+ mod = require.resolve(`${base}/package.json`)
25
+ } catch (err) {
26
+ if (err.code === 'MODULE_NOT_FOUND') {
27
+ throw new Error(`No binary found for target '${platform}-${arch}'`)
28
+ } else {
29
+ throw err
30
+ }
31
+ }
32
+
33
+ return path.join(mod, '..', require(mod).bin[filename])
34
+ }
package/lib/spawn.js CHANGED
@@ -1,32 +1,8 @@
1
- const path = require('path')
2
-
3
- module.exports = function spawn (referrer, opts = {}) {
4
- const {
5
- platform = process.platform,
6
- arch = process.arch
7
- } = opts
8
-
9
- const filename = path.basename(referrer)
10
-
11
- const base = `bare-runtime-${platform}-${arch}`
12
-
13
- let mod
14
- try {
15
- mod = require.resolve(`${base}/package.json`)
16
- } catch (err) {
17
- if (err.code === 'MODULE_NOT_FOUND') {
18
- throw new Error(`No binary found for target ${platform}-${arch}`)
19
- } else {
20
- throw err
21
- }
22
- }
23
-
24
- const pkg = require(mod)
25
-
26
- const bin = path.join(mod, '..', pkg.bin[filename])
1
+ const runtime = require('..')
27
2
 
3
+ module.exports = function spawn (referrer, opts) {
28
4
  try {
29
- require('child_process').execFileSync(bin, process.argv.slice(2), { stdio: 'inherit' })
5
+ require('child_process').execFileSync(runtime(referrer, opts), process.argv.slice(2), { stdio: 'inherit' })
30
6
  } catch (err) {
31
7
  process.exitCode = err.status || 1
32
8
  }
package/package.json CHANGED
@@ -1,14 +1,19 @@
1
1
  {
2
2
  "name": "bare-runtime",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Prebuilt Bare binaries for macOS, Linux, Android, and Windows",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./spawn": "./lib/spawn.js"
8
+ },
5
9
  "bin": {
6
10
  "bare": "bin/bare"
7
11
  },
8
12
  "files": [
9
13
  "NOTICE",
10
14
  "bin",
11
- "lib"
15
+ "lib",
16
+ "index.js"
12
17
  ],
13
18
  "scripts": {
14
19
  "test": "standard"
@@ -24,16 +29,16 @@
24
29
  },
25
30
  "homepage": "https://github.com/holepunchto/bare-runtime",
26
31
  "optionalDependencies": {
27
- "bare-runtime-android-arm": "1.0.6",
28
- "bare-runtime-android-arm64": "1.0.6",
29
- "bare-runtime-android-ia32": "1.0.6",
30
- "bare-runtime-android-x64": "1.0.6",
31
- "bare-runtime-darwin-arm64": "1.0.6",
32
- "bare-runtime-darwin-x64": "1.0.6",
33
- "bare-runtime-linux-arm64": "1.0.6",
34
- "bare-runtime-linux-x64": "1.0.6",
35
- "bare-runtime-win32-arm64": "1.0.6",
36
- "bare-runtime-win32-x64": "1.0.6"
32
+ "bare-runtime-android-arm": "1.0.8",
33
+ "bare-runtime-android-arm64": "1.0.8",
34
+ "bare-runtime-android-ia32": "1.0.8",
35
+ "bare-runtime-android-x64": "1.0.8",
36
+ "bare-runtime-darwin-arm64": "1.0.8",
37
+ "bare-runtime-darwin-x64": "1.0.8",
38
+ "bare-runtime-linux-arm64": "1.0.8",
39
+ "bare-runtime-linux-x64": "1.0.8",
40
+ "bare-runtime-win32-arm64": "1.0.8",
41
+ "bare-runtime-win32-x64": "1.0.8"
37
42
  },
38
43
  "devDependencies": {
39
44
  "standard": "^17.0.0"