@orkestrel/process 0.0.11 → 0.0.13
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/dist/src/core/index.d.cts +6 -2
- package/dist/src/core/index.d.ts +6 -2
- package/dist/src/server/index.cjs +21 -12
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +17 -9
- package/dist/src/server/index.d.ts +17 -9
- package/dist/src/server/index.js +22 -13
- package/dist/src/server/index.js.map +1 -1
- package/package.json +10 -10
|
@@ -64,8 +64,12 @@ export declare interface DetachOptions {
|
|
|
64
64
|
* Supplies the lookup inputs for resolving a command file to an executable path.
|
|
65
65
|
*
|
|
66
66
|
* @remarks
|
|
67
|
-
* `workspace`
|
|
68
|
-
*
|
|
67
|
+
* {@link buildExecutableCandidates} searches `workspace` before `PATH`, matching Windows command
|
|
68
|
+
* semantics. For an extensionless Windows name, it enumerates `PATHEXT` candidates. For an
|
|
69
|
+
* extension-bearing Windows name, it enumerates the literal path before `PATHEXT` candidates.
|
|
70
|
+
* `environment` is the child's effective environment, so the lookup reads the same `PATH` and
|
|
71
|
+
* `PATHEXT` the child will. On a lookup miss, {@link buildSpawn} preserves the command file as
|
|
72
|
+
* written for native spawning.
|
|
69
73
|
*/
|
|
70
74
|
export declare interface ExecutableOptions {
|
|
71
75
|
/** Names the directory searched first. Default: the current working directory. */
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -64,8 +64,12 @@ export declare interface DetachOptions {
|
|
|
64
64
|
* Supplies the lookup inputs for resolving a command file to an executable path.
|
|
65
65
|
*
|
|
66
66
|
* @remarks
|
|
67
|
-
* `workspace`
|
|
68
|
-
*
|
|
67
|
+
* {@link buildExecutableCandidates} searches `workspace` before `PATH`, matching Windows command
|
|
68
|
+
* semantics. For an extensionless Windows name, it enumerates `PATHEXT` candidates. For an
|
|
69
|
+
* extension-bearing Windows name, it enumerates the literal path before `PATHEXT` candidates.
|
|
70
|
+
* `environment` is the child's effective environment, so the lookup reads the same `PATH` and
|
|
71
|
+
* `PATHEXT` the child will. On a lookup miss, {@link buildSpawn} preserves the command file as
|
|
72
|
+
* written for native spawning.
|
|
69
73
|
*/
|
|
70
74
|
export declare interface ExecutableOptions {
|
|
71
75
|
/** Names the directory searched first. Default: the current working directory. */
|
|
@@ -274,15 +274,15 @@ function isFile(target) {
|
|
|
274
274
|
*
|
|
275
275
|
* @remarks
|
|
276
276
|
* Windows alone needs this list: the host searches the working directory before `PATH` and applies
|
|
277
|
-
* `PATHEXT`, and Node reproduces neither for a direct spawn. Within each searched directory
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
* `report.txt
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
* `PATHEXT`
|
|
284
|
-
* treats as the same file. A non-Windows platform returns an empty list
|
|
285
|
-
* its own lookup.
|
|
277
|
+
* `PATHEXT`, and Node reproduces neither for a direct spawn. Within each searched directory,
|
|
278
|
+
* {@link buildExecutableCandidates} enumerates `PATHEXT` candidates for an extensionless name. For
|
|
279
|
+
* an extension-bearing name, it enumerates the literal path before `PATHEXT` candidates, so
|
|
280
|
+
* `report.txt` resolves to a `report.txt` file where one exists and to `report.txt.cmd` where none
|
|
281
|
+
* does. The lookup reads the child's effective environment, so an overridden `PATH` selects the
|
|
282
|
+
* executable the child would have found. A POSIX host resolves the file itself, so the candidate
|
|
283
|
+
* list there is empty. A `PATHEXT` candidate keeps the extension spelling from `PATHEXT`, which the
|
|
284
|
+
* case-insensitive host treats as the same file. A non-Windows platform returns an empty list
|
|
285
|
+
* because `execvp` performs its own lookup.
|
|
286
286
|
*
|
|
287
287
|
* @param file - The command executable name or path
|
|
288
288
|
* @param workspace - The directory searched first
|
|
@@ -297,7 +297,8 @@ function isFile(target) {
|
|
|
297
297
|
*/
|
|
298
298
|
function buildExecutableCandidates(file, workspace, environment, platform) {
|
|
299
299
|
if (platform !== "win32") return Object.freeze([]);
|
|
300
|
-
const
|
|
300
|
+
const extensions = (readPlatformVariable(environment, "PATHEXT", platform) ?? _src_core.PROCESS_PATHEXT).split(";").filter((extension) => extension.length > 0);
|
|
301
|
+
const candidates = node_path.win32.extname(file).length === 0 ? extensions.map((extension) => `${file}${extension}`) : [file, ...extensions.map((extension) => `${file}${extension}`)];
|
|
301
302
|
const directories = file.includes("/") || file.includes("\\") ? [workspace] : [workspace, ...(readPlatformVariable(environment, "PATH", platform) ?? "").split(";")];
|
|
302
303
|
const targets = [];
|
|
303
304
|
for (const directory of directories) {
|
|
@@ -310,6 +311,10 @@ function buildExecutableCandidates(file, workspace, environment, platform) {
|
|
|
310
311
|
* Resolves a command file to the executable path the host would launch, or to `undefined` on a POSIX
|
|
311
312
|
* host, which performs its own lookup.
|
|
312
313
|
*
|
|
314
|
+
* @remarks
|
|
315
|
+
* A Windows lookup miss also returns `undefined`. {@link buildSpawn} preserves the command file as
|
|
316
|
+
* written for native spawning.
|
|
317
|
+
*
|
|
313
318
|
* @param file - The command executable name or path
|
|
314
319
|
* @param options - The directory searched first and the child's effective environment
|
|
315
320
|
* @returns The resolved absolute path, or `undefined` when no candidate is a regular file
|
|
@@ -394,6 +399,10 @@ function buildPlatformSpawn(command, file, environment, platform) {
|
|
|
394
399
|
/**
|
|
395
400
|
* Builds the resolved spawn form of one command for the current host.
|
|
396
401
|
*
|
|
402
|
+
* @remarks
|
|
403
|
+
* When executable lookup returns no regular-file candidate, {@link buildSpawn} preserves the
|
|
404
|
+
* command file as written for native spawning.
|
|
405
|
+
*
|
|
397
406
|
* @param command - The executable and its argument vector
|
|
398
407
|
* @param options - The directory searched first and the child's effective environment
|
|
399
408
|
* @returns The file, argument vector, and verbatim flag to spawn with
|
|
@@ -571,7 +580,7 @@ function killProcess(child, signal) {
|
|
|
571
580
|
}
|
|
572
581
|
process.kill(-child.pid, signal);
|
|
573
582
|
} catch (error) {
|
|
574
|
-
if (error
|
|
583
|
+
if ((0, _orkestrel_contract.isError)(error) && "code" in error && error.code === "ESRCH") {
|
|
575
584
|
(0, _orkestrel_contract.holds)(() => child.kill(signal));
|
|
576
585
|
return;
|
|
577
586
|
}
|
|
@@ -1846,7 +1855,7 @@ var ProcessManager = class {
|
|
|
1846
1855
|
}
|
|
1847
1856
|
stop(target) {
|
|
1848
1857
|
if (target === void 0) return this.#stopAll();
|
|
1849
|
-
if (
|
|
1858
|
+
if ((0, _orkestrel_contract.isString)(target)) return this.#stopOne(target);
|
|
1850
1859
|
return this.#stopMany(target);
|
|
1851
1860
|
}
|
|
1852
1861
|
/**
|