bare-runtime 1.22.0 → 1.22.2
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.
- package/README.md +39 -1
- package/bin/bare +5 -6
- package/lib/spawn.js +38 -4
- package/package.json +24 -14
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/bin/bare
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
require('../lib/spawn')(__filename, {
|
|
3
|
-
'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
)
|
|
2
|
+
require('../lib/spawn')(__filename, {
|
|
3
|
+
stdio: 'inherit',
|
|
4
|
+
suppressSignals: true,
|
|
5
|
+
forwardExitCode: true
|
|
6
|
+
})
|
package/lib/spawn.js
CHANGED
|
@@ -1,22 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const os = require('os')
|
|
3
|
+
const process = require('process')
|
|
2
4
|
const childProcess = require('child_process')
|
|
3
5
|
const runtime = require('..')
|
|
4
6
|
|
|
5
7
|
module.exports = function spawn(referrer, opts) {
|
|
6
8
|
if (typeof referrer === 'object' && referrer !== null) {
|
|
7
9
|
opts = referrer
|
|
8
|
-
referrer = '
|
|
10
|
+
referrer = 'bare'
|
|
9
11
|
} else if (typeof referrer !== 'string') {
|
|
10
|
-
referrer = '
|
|
12
|
+
referrer = 'bare'
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
if (!opts) opts = {}
|
|
14
16
|
|
|
15
17
|
const {
|
|
18
|
+
suppressSignals = false,
|
|
19
|
+
forwardExitCode = false,
|
|
16
20
|
args = typeof Bare !== 'undefined'
|
|
17
21
|
? Bare.argv.slice(2)
|
|
18
22
|
: process.argv.slice(2)
|
|
19
23
|
} = opts
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
const bin = runtime(referrer, opts)
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
fs.accessSync(bin, fs.constants.X_OK)
|
|
29
|
+
} catch {
|
|
30
|
+
fs.chmodSync(bin, 0o755)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const job = childProcess.spawn(bin, args, opts)
|
|
34
|
+
|
|
35
|
+
if (suppressSignals) {
|
|
36
|
+
process.on('SIGINT', onsignal).on('SIGTERM', onsignal)
|
|
37
|
+
|
|
38
|
+
job.once('exit', () => {
|
|
39
|
+
process.off('SIGINT', onsignal).off('SIGTERM', onsignal)
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (forwardExitCode) {
|
|
44
|
+
job.once('exit', (code, signal) => {
|
|
45
|
+
if (signal) {
|
|
46
|
+
process.exitCode = 0x80 | os.constants.signals[signal]
|
|
47
|
+
} else {
|
|
48
|
+
process.exitCode = code
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return job
|
|
22
54
|
}
|
|
55
|
+
|
|
56
|
+
function onsignal() {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-runtime",
|
|
3
|
-
"version": "1.22.
|
|
3
|
+
"version": "1.22.2",
|
|
4
4
|
"description": "Prebuilt Bare binaries for macOS, iOS, Linux, Android, and Windows",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
"bare": "bare-subprocess",
|
|
25
25
|
"default": "child_process"
|
|
26
26
|
},
|
|
27
|
+
"fs": {
|
|
28
|
+
"bare": "bare-fs",
|
|
29
|
+
"default": "fs"
|
|
30
|
+
},
|
|
27
31
|
"os": {
|
|
28
32
|
"bare": "bare-os",
|
|
29
33
|
"default": "os"
|
|
@@ -31,6 +35,10 @@
|
|
|
31
35
|
"path": {
|
|
32
36
|
"bare": "bare-path",
|
|
33
37
|
"default": "path"
|
|
38
|
+
},
|
|
39
|
+
"process": {
|
|
40
|
+
"bare": "bare-process",
|
|
41
|
+
"default": "process"
|
|
34
42
|
}
|
|
35
43
|
},
|
|
36
44
|
"scripts": {
|
|
@@ -47,24 +55,26 @@
|
|
|
47
55
|
},
|
|
48
56
|
"homepage": "https://github.com/holepunchto/bare-runtime",
|
|
49
57
|
"dependencies": {
|
|
58
|
+
"bare-fs": "^4.4.4",
|
|
50
59
|
"bare-os": "^3.0.1",
|
|
51
60
|
"bare-path": "^3.0.0",
|
|
61
|
+
"bare-process": "^4.2.1",
|
|
52
62
|
"bare-subprocess": "^5.0.0"
|
|
53
63
|
},
|
|
54
64
|
"optionalDependencies": {
|
|
55
|
-
"bare-runtime-android-arm": "1.22.
|
|
56
|
-
"bare-runtime-android-arm64": "1.22.
|
|
57
|
-
"bare-runtime-android-ia32": "1.22.
|
|
58
|
-
"bare-runtime-android-x64": "1.22.
|
|
59
|
-
"bare-runtime-darwin-arm64": "1.22.
|
|
60
|
-
"bare-runtime-darwin-x64": "1.22.
|
|
61
|
-
"bare-runtime-ios-arm64": "1.22.
|
|
62
|
-
"bare-runtime-ios-arm64-simulator": "1.22.
|
|
63
|
-
"bare-runtime-ios-x64-simulator": "1.22.
|
|
64
|
-
"bare-runtime-linux-arm64": "1.22.
|
|
65
|
-
"bare-runtime-linux-x64": "1.22.
|
|
66
|
-
"bare-runtime-win32-arm64": "1.22.
|
|
67
|
-
"bare-runtime-win32-x64": "1.22.
|
|
65
|
+
"bare-runtime-android-arm": "1.22.2",
|
|
66
|
+
"bare-runtime-android-arm64": "1.22.2",
|
|
67
|
+
"bare-runtime-android-ia32": "1.22.2",
|
|
68
|
+
"bare-runtime-android-x64": "1.22.2",
|
|
69
|
+
"bare-runtime-darwin-arm64": "1.22.2",
|
|
70
|
+
"bare-runtime-darwin-x64": "1.22.2",
|
|
71
|
+
"bare-runtime-ios-arm64": "1.22.2",
|
|
72
|
+
"bare-runtime-ios-arm64-simulator": "1.22.2",
|
|
73
|
+
"bare-runtime-ios-x64-simulator": "1.22.2",
|
|
74
|
+
"bare-runtime-linux-arm64": "1.22.2",
|
|
75
|
+
"bare-runtime-linux-x64": "1.22.2",
|
|
76
|
+
"bare-runtime-win32-arm64": "1.22.2",
|
|
77
|
+
"bare-runtime-win32-x64": "1.22.2"
|
|
68
78
|
},
|
|
69
79
|
"devDependencies": {
|
|
70
80
|
"prettier": "^3.3.3",
|