@orkestrel/process 0.0.11 → 0.0.12

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.
@@ -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` is searched before `PATH`, matching Windows command semantics. `environment` is the
68
- * child's effective environment, so the lookup reads the same `PATH` and `PATHEXT` the child will.
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. */
@@ -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` is searched before `PATH`, matching Windows command semantics. `environment` is the
68
- * child's effective environment, so the lookup reads the same `PATH` and `PATHEXT` the child will.
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 the
278
- * literal name is tried first and each `PATHEXT` candidate after it, whether or not the name already
279
- * carries an extension — so `report.txt` resolves to a `report.txt` file where one exists and to
280
- * `report.txt.cmd` where none does. The lookup reads the child's effective environment, so an
281
- * overridden `PATH` selects the executable the child would have found. A POSIX host resolves the
282
- * file itself, so the candidate list there is empty. An appended extension is spelled the way
283
- * `PATHEXT` spells it rather than the way the directory entry does, which the case-insensitive host
284
- * treats as the same file. A non-Windows platform returns an empty list because `execvp` performs
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 candidates = [file, ...(readPlatformVariable(environment, "PATHEXT", platform) ?? _src_core.PROCESS_PATHEXT).split(";").filter((extension) => extension.length > 0).map((extension) => `${file}${extension}`)];
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