bare-runtime 1.22.0 → 1.22.1-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 (3) hide show
  1. package/README.md +39 -1
  2. package/lib/spawn.js +12 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -3,9 +3,47 @@
3
3
  Prebuilt Bare binaries for macOS, iOS, Linux, Android, and Windows.
4
4
 
5
5
  ```
6
- npm i bare-runtime
6
+ npm i [-g] bare-runtime
7
7
  ```
8
8
 
9
+ ## API
10
+
11
+ > [!WARNING]
12
+ > These functions are currently subject to change between releases and are not by covered Semantic Versioning. The version of the prebuilds strictly match the corresponding Bare version. If your code depends on the APIs make sure to specify a fixed version (`1.2.3`) when declaring the module dependency.
13
+
14
+ #### `const prebuild = runtime([referrer][, options])`
15
+
16
+ Get the path to the Bare binary prebuild for the current platform. Will throw an error if no matching binary prebuild is found.
17
+
18
+ Options include:
19
+
20
+ ```js
21
+ options = {
22
+ platform: process.platform,
23
+ arch: process.arch
24
+ }
25
+ ```
26
+
27
+ ### Spawning
28
+
29
+ The `bare-runtime/spawn` module provides a convenient way to spawn the Bare binary prebuilds as child processes, adding appropriate executable permissions as required.
30
+
31
+ #### `const process = spawn([referrer][, options])`
32
+
33
+ Options include:
34
+
35
+ ```js
36
+ options = {
37
+ platform: process.platform,
38
+ arch: process.arch,
39
+ args: process.argv.slice(2)
40
+ }
41
+ ```
42
+
43
+ ## CLI
44
+
45
+ The module exposes a CLI that as a convenience will spawn the Bare binary that matches your platform. See <https://github.com/holepunchto/bare#usage> for details on the `bare` CLI.
46
+
9
47
  ## License
10
48
 
11
49
  Apache-2.0
package/lib/spawn.js CHANGED
@@ -1,13 +1,13 @@
1
- /* global Bare */
1
+ const fs = require('fs')
2
2
  const childProcess = require('child_process')
3
3
  const runtime = require('..')
4
4
 
5
5
  module.exports = function spawn(referrer, opts) {
6
6
  if (typeof referrer === 'object' && referrer !== null) {
7
7
  opts = referrer
8
- referrer = 'ninja'
8
+ referrer = 'bare'
9
9
  } else if (typeof referrer !== 'string') {
10
- referrer = 'ninja'
10
+ referrer = 'bare'
11
11
  }
12
12
 
13
13
  if (!opts) opts = {}
@@ -18,5 +18,13 @@ module.exports = function spawn(referrer, opts) {
18
18
  : process.argv.slice(2)
19
19
  } = opts
20
20
 
21
- return childProcess.spawn(runtime(referrer, opts), args, opts)
21
+ const bin = runtime(referrer, opts)
22
+
23
+ try {
24
+ fs.accessSync(bin, fs.constants.X_OK)
25
+ } catch {
26
+ fs.chmodSync(bin, 0o755)
27
+ }
28
+
29
+ return childProcess.spawn(bin, args, opts)
22
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-runtime",
3
- "version": "1.22.0",
3
+ "version": "1.22.1-0",
4
4
  "description": "Prebuilt Bare binaries for macOS, iOS, Linux, Android, and Windows",
5
5
  "exports": {
6
6
  ".": "./index.js",