@alphahydrae/exec 1.0.2 → 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.
Files changed (2) hide show
  1. package/exec.js +15 -4
  2. package/package.json +7 -7
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
- native.execvp(file, [file, ...args]);
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": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "The execvp function for Node.js",
5
5
  "main": "exec.js",
6
6
  "repository": {
@@ -67,11 +67,11 @@
67
67
  "node": "^18 || ^20 || ^22"
68
68
  },
69
69
  "optionalDependencies": {
70
- "@alphahydrae/exec-darwin-x64": "1.0.2",
71
- "@alphahydrae/exec-linux-x64-gnu": "1.0.2",
72
- "@alphahydrae/exec-linux-x64-musl": "1.0.2",
73
- "@alphahydrae/exec-darwin-arm64": "1.0.2",
74
- "@alphahydrae/exec-linux-arm64-gnu": "1.0.2",
75
- "@alphahydrae/exec-linux-arm64-musl": "1.0.2"
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
  }