@alphahydrae/exec 0.2.6 → 1.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.
- package/README.md +15 -14
- package/exec.js +15 -4
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@ This package was developed to be used in Node.js scripts that are frontends to
|
|
|
20
20
|
execute other commands. For example, a script that would build and execute a
|
|
21
21
|
complex SSH or Ansible command.
|
|
22
22
|
|
|
23
|
+
[](https://www.npmjs.com/package/@alphahydrae/exec)
|
|
23
24
|
[](https://github.com/AlphaHydrae/node-exec/actions/workflows/build.yml)
|
|
24
25
|
[](https://opensource.org/licenses/MIT)
|
|
25
26
|
|
|
@@ -42,19 +43,19 @@ npm i @alphahydrae/exec
|
|
|
42
43
|
|
|
43
44
|
| OS & Architecture | Node.js 18 | Node.js 20 | Node.js 22 |
|
|
44
45
|
| :---------------- | :--------: | :--------: | :--------: |
|
|
45
|
-
| macOS x64 | ✅
|
|
46
|
-
| macOS arm64 | ✅
|
|
47
|
-
| Linux x64 gnu | ✅
|
|
48
|
-
| Linux x64 musl | ✅
|
|
49
|
-
| Linux arm64 gnu | ✅
|
|
50
|
-
| Linux arm64 musl | ✅
|
|
51
|
-
| Linux arm gnu | ❌
|
|
52
|
-
| Android arm64 | ❌
|
|
53
|
-
| Android armv7 | ❌
|
|
54
|
-
| FreeBSD x64 | ❌
|
|
55
|
-
| Windows x64 | ❌
|
|
56
|
-
| Windows x32 | ❌
|
|
57
|
-
| Windows arm64 | ❌
|
|
46
|
+
| macOS x64 | ✅ | ✅ | ✅ |
|
|
47
|
+
| macOS arm64 | ✅ | ✅ | ✅ |
|
|
48
|
+
| Linux x64 gnu | ✅ | ✅ | ✅ |
|
|
49
|
+
| Linux x64 musl | ✅ | ✅ | ✅ |
|
|
50
|
+
| Linux arm64 gnu | ✅ | ✅ | ✅ |
|
|
51
|
+
| Linux arm64 musl | ✅ | ✅ | ✅ |
|
|
52
|
+
| Linux arm gnu | ❌ | ❌ | ❌ |
|
|
53
|
+
| Android arm64 | ❌ | ❌ | ❌ |
|
|
54
|
+
| Android armv7 | ❌ | ❌ | ❌ |
|
|
55
|
+
| FreeBSD x64 | ❌ | ❌ | ❌ |
|
|
56
|
+
| Windows x64 | ❌ | ❌ | ❌ |
|
|
57
|
+
| Windows x32 | ❌ | ❌ | ❌ |
|
|
58
|
+
| Windows arm64 | ❌ | ❌ | ❌ |
|
|
58
59
|
|
|
59
60
|
> The `exec` family of functions is part of the
|
|
60
61
|
> [POSIX](https://en.wikipedia.org/wiki/POSIX) operating system API, so it will
|
|
@@ -72,4 +73,4 @@ following conversations:
|
|
|
72
73
|
Also a big thank you to the following Rust projects for making it easy:
|
|
73
74
|
|
|
74
75
|
- [NAPI-RS](https://napi.rs) (build pre-compiled Node.js addons in Rust)
|
|
75
|
-
- [nix](https://docs.rs/nix) (Rust-friendly bindings to the various
|
|
76
|
+
- [nix](https://docs.rs/nix) (Rust-friendly bindings to the various \*nix system functions)
|
package/exec.js
CHANGED
|
@@ -4,7 +4,7 @@ const native = require('./index.js');
|
|
|
4
4
|
* Performs the execvp system call with the given file and arguments, replacing
|
|
5
5
|
* the current process image with the new one.
|
|
6
6
|
*
|
|
7
|
-
* This function does not return if successful, as the current process is
|
|
7
|
+
* This function does not return if successful, as the current process image is
|
|
8
8
|
* replaced by the new one. An error may be thrown, with an error message
|
|
9
9
|
* containing the error code returned by execvp.
|
|
10
10
|
*
|
|
@@ -15,12 +15,23 @@ const native = require('./index.js');
|
|
|
15
15
|
* @param {string} file The file to execute. If not a path, the PATH environment
|
|
16
16
|
* variable is searched.
|
|
17
17
|
* @param {string[]} args The arguments to pass to the new process. The `file`
|
|
18
|
-
* argument is automatically prepended to the arguments
|
|
18
|
+
* argument is automatically prepended to the arguments
|
|
19
|
+
* and passed as the first argument to the `execvp`
|
|
20
|
+
* system call.
|
|
21
|
+
* @param {Object} [options] Optional options.
|
|
22
|
+
* @param {string} [options.arg0=file] The value to pass as the first argument
|
|
23
|
+
* to the `execvp` system call. Defaults to
|
|
24
|
+
* the `file` argument.
|
|
19
25
|
* @throws {Error} If the execvp system call fails.
|
|
20
26
|
*/
|
|
21
|
-
module.exports.execvp = function (file, args) {
|
|
27
|
+
module.exports.execvp = function (file, args, options = {}) {
|
|
28
|
+
const arg0 = options.arg0 ?? file;
|
|
29
|
+
|
|
30
|
+
// Prevent the standard streams from being closed when the process is
|
|
31
|
+
// replaced.
|
|
22
32
|
native.doNotCloseOnExit(process.stdin.fd);
|
|
23
33
|
native.doNotCloseOnExit(process.stdout.fd);
|
|
24
34
|
native.doNotCloseOnExit(process.stderr.fd);
|
|
25
|
-
|
|
35
|
+
|
|
36
|
+
native.execvp(file, [arg0, ...args]);
|
|
26
37
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alphahydrae/exec",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "The execvp function for Node.js",
|
|
5
5
|
"main": "exec.js",
|
|
6
6
|
"repository": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"lint": "cargo clippy",
|
|
51
51
|
"prepublishOnly": "napi prepublish -t npm",
|
|
52
52
|
"test": "jest",
|
|
53
|
-
"version": "napi version"
|
|
53
|
+
"version": "napi version && npm run build:package && prettier --write ./npm/*/package.json"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@napi-rs/cli": "^2.18.4",
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"node": "^18 || ^20 || ^22"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
|
-
"@alphahydrae/exec-darwin-x64": "
|
|
71
|
-
"@alphahydrae/exec-linux-x64-gnu": "
|
|
72
|
-
"@alphahydrae/exec-linux-x64-musl": "
|
|
73
|
-
"@alphahydrae/exec-darwin-arm64": "
|
|
74
|
-
"@alphahydrae/exec-linux-arm64-gnu": "
|
|
75
|
-
"@alphahydrae/exec-linux-arm64-musl": "
|
|
70
|
+
"@alphahydrae/exec-darwin-x64": "1.1.0",
|
|
71
|
+
"@alphahydrae/exec-linux-x64-gnu": "1.1.0",
|
|
72
|
+
"@alphahydrae/exec-linux-x64-musl": "1.1.0",
|
|
73
|
+
"@alphahydrae/exec-darwin-arm64": "1.1.0",
|
|
74
|
+
"@alphahydrae/exec-linux-arm64-gnu": "1.1.0",
|
|
75
|
+
"@alphahydrae/exec-linux-arm64-musl": "1.1.0"
|
|
76
76
|
}
|
|
77
77
|
}
|