@socketsecurity/lib 1.0.5 → 1.1.1

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 (57) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/arrays.d.ts +143 -0
  3. package/dist/arrays.js.map +2 -2
  4. package/dist/effects/text-shimmer.js +2 -1
  5. package/dist/effects/text-shimmer.js.map +2 -2
  6. package/dist/fs.d.ts +595 -23
  7. package/dist/fs.js.map +2 -2
  8. package/dist/git.d.ts +488 -41
  9. package/dist/git.js.map +2 -2
  10. package/dist/github.d.ts +361 -12
  11. package/dist/github.js.map +2 -2
  12. package/dist/http-request.d.ts +463 -4
  13. package/dist/http-request.js.map +2 -2
  14. package/dist/json.d.ts +177 -4
  15. package/dist/json.js.map +2 -2
  16. package/dist/logger.d.ts +822 -67
  17. package/dist/logger.js +653 -46
  18. package/dist/logger.js.map +2 -2
  19. package/dist/objects.d.ts +386 -10
  20. package/dist/objects.js.map +2 -2
  21. package/dist/path.d.ts +270 -6
  22. package/dist/path.js.map +2 -2
  23. package/dist/promises.d.ts +432 -27
  24. package/dist/promises.js.map +2 -2
  25. package/dist/spawn.d.ts +239 -12
  26. package/dist/spawn.js.map +2 -2
  27. package/dist/spinner.d.ts +260 -20
  28. package/dist/spinner.js +201 -63
  29. package/dist/spinner.js.map +2 -2
  30. package/dist/stdio/clear.d.ts +130 -9
  31. package/dist/stdio/clear.js.map +2 -2
  32. package/dist/stdio/divider.d.ts +106 -10
  33. package/dist/stdio/divider.js +10 -0
  34. package/dist/stdio/divider.js.map +2 -2
  35. package/dist/stdio/footer.d.ts +70 -3
  36. package/dist/stdio/footer.js.map +2 -2
  37. package/dist/stdio/header.d.ts +93 -12
  38. package/dist/stdio/header.js.map +2 -2
  39. package/dist/stdio/mask.d.ts +82 -14
  40. package/dist/stdio/mask.js +25 -4
  41. package/dist/stdio/mask.js.map +2 -2
  42. package/dist/stdio/progress.d.ts +112 -15
  43. package/dist/stdio/progress.js +43 -3
  44. package/dist/stdio/progress.js.map +2 -2
  45. package/dist/stdio/prompts.d.ts +95 -5
  46. package/dist/stdio/prompts.js.map +2 -2
  47. package/dist/stdio/stderr.d.ts +114 -11
  48. package/dist/stdio/stderr.js.map +2 -2
  49. package/dist/stdio/stdout.d.ts +107 -11
  50. package/dist/stdio/stdout.js.map +2 -2
  51. package/dist/strings.d.ts +357 -28
  52. package/dist/strings.js.map +2 -2
  53. package/dist/validation/json-parser.d.ts +226 -7
  54. package/dist/validation/json-parser.js.map +2 -2
  55. package/dist/validation/types.d.ts +114 -8
  56. package/dist/validation/types.js.map +1 -1
  57. package/package.json +1 -1
package/dist/spawn.d.ts CHANGED
@@ -1,6 +1,18 @@
1
1
  // Define BufferEncoding type for TypeScript compatibility.
2
2
  type BufferEncoding = globalThis.BufferEncoding;
3
- // Type for promise-spawn options.
3
+ /**
4
+ * Options for spawning a child process with promise-based completion.
5
+ *
6
+ * @property {string | undefined} cwd - Current working directory for the process
7
+ * @property {boolean | undefined} stdioString - Convert stdio output to strings (default: `true`)
8
+ * @property {StdioType | undefined} stdio - Stdio configuration (`'pipe'`, `'ignore'`, `'inherit'`, or array)
9
+ * @property {NodeJS.ProcessEnv | undefined} env - Environment variables for the process
10
+ * @property {boolean | string | undefined} shell - Whether to run command in shell, or path to shell
11
+ * @property {AbortSignal | undefined} signal - Signal to abort the process
12
+ * @property {number | undefined} timeout - Maximum time in milliseconds before killing the process
13
+ * @property {number | undefined} uid - User identity of the process (POSIX only)
14
+ * @property {number | undefined} gid - Group identity of the process (POSIX only)
15
+ */
4
16
  export type PromiseSpawnOptions = {
5
17
  cwd?: string | undefined;
6
18
  stdioString?: boolean | undefined;
@@ -12,7 +24,20 @@ export type PromiseSpawnOptions = {
12
24
  uid?: number | undefined;
13
25
  gid?: number | undefined;
14
26
  };
15
- // Type for promise-spawn result.
27
+ /**
28
+ * Result returned by {@link spawn} when the child process completes.
29
+ * This is a Promise that resolves with process exit information and output,
30
+ * with additional properties for accessing the running process and stdin stream.
31
+ *
32
+ * @property {ChildProcessType} process - The running child process instance
33
+ * @property {WritableStreamType | null} stdin - Writable stream for process stdin, or `null` if not piped
34
+ *
35
+ * @example
36
+ * const result = spawn('echo', ['hello'])
37
+ * result.stdin?.write('additional input\n')
38
+ * const { code, stdout } = await result
39
+ * console.log(stdout) // 'hello'
40
+ */
16
41
  export type PromiseSpawnResult = Promise<{
17
42
  cmd: string;
18
43
  args: string[] | readonly string[];
@@ -25,7 +50,29 @@ export type PromiseSpawnResult = Promise<{
25
50
  stdin: WritableStreamType | null;
26
51
  };
27
52
  /**
28
- * Check if a value is a spawn error.
53
+ * Error object thrown when a spawned process fails.
54
+ * Extends the standard Error with process-specific information including exit code,
55
+ * signal, command details, and captured output.
56
+ *
57
+ * @property {string[]} args - Arguments passed to the command
58
+ * @property {string} cmd - Command that was executed
59
+ * @property {number} code - Process exit code
60
+ * @property {string} name - Error name (typically `'Error'`)
61
+ * @property {string} message - Error message describing the failure
62
+ * @property {NodeJS.Signals | null} signal - Signal that terminated the process, if any
63
+ * @property {string} stack - Stack trace of the error
64
+ * @property {string | Buffer} stderr - Standard error output from the process
65
+ * @property {string | Buffer} stdout - Standard output from the process
66
+ *
67
+ * @example
68
+ * try {
69
+ * await spawn('exit', ['1'])
70
+ * } catch (error) {
71
+ * if (isSpawnError(error)) {
72
+ * console.error(`Command failed with code ${error.code}`)
73
+ * console.error(`stderr: ${error.stderr}`)
74
+ * }
75
+ * }
29
76
  */
30
77
  export type SpawnError = {
31
78
  args: string[];
@@ -38,17 +85,67 @@ export type SpawnError = {
38
85
  stderr: string | Buffer;
39
86
  stdout: string | Buffer;
40
87
  };
88
+ /**
89
+ * Spawn error variant where stdout and stderr are guaranteed to be strings.
90
+ * This type is used when `stdioString: true` is set in spawn options.
91
+ *
92
+ * @property {string} stdout - Standard output as a string
93
+ * @property {string} stderr - Standard error as a string
94
+ */
41
95
  export type SpawnErrorWithOutputString = SpawnError & {
42
96
  stdout: string;
43
97
  stderr: string;
44
98
  };
99
+ /**
100
+ * Spawn error variant where stdout and stderr are guaranteed to be Buffers.
101
+ * This type is used when `stdioString: false` is set in spawn options.
102
+ *
103
+ * @property {Buffer} stdout - Standard output as a Buffer
104
+ * @property {Buffer} stderr - Standard error as a Buffer
105
+ */
45
106
  export type SpawnErrorWithOutputBuffer = SpawnError & {
46
107
  stdout: Buffer;
47
108
  stderr: Buffer;
48
109
  };
110
+ /**
111
+ * Extra options passed to the underlying promise-spawn implementation.
112
+ * This is an open-ended object for passing additional metadata or configuration.
113
+ */
49
114
  export type SpawnExtra = Record<string, unknown>;
115
+ /**
116
+ * Valid values for individual stdio streams.
117
+ * - `'pipe'` - Creates a pipe between child and parent (default)
118
+ * - `'ignore'` - Ignores the stream
119
+ * - `'inherit'` - Uses parent's stream
120
+ * - `'overlapped'` - Windows-specific overlapped I/O
121
+ */
50
122
  export type IOType = 'pipe' | 'ignore' | 'inherit' | 'overlapped';
123
+ /**
124
+ * Configuration for process stdio (stdin, stdout, stderr) streams.
125
+ * Can be a single value applied to all streams, or an array specifying each stream individually.
126
+ * - `'ipc'` - Creates an IPC channel for communication with the parent
127
+ *
128
+ * @example
129
+ * // All streams piped
130
+ * stdio: 'pipe'
131
+ *
132
+ * @example
133
+ * // Custom configuration per stream: [stdin, stdout, stderr]
134
+ * stdio: ['ignore', 'pipe', 'pipe']
135
+ */
51
136
  export type StdioType = IOType | 'ipc' | Array<IOType | 'ipc'>;
137
+ /**
138
+ * Result object returned by {@link spawnSync} when the child process completes synchronously.
139
+ *
140
+ * @template T - Type of stdout/stderr (string or Buffer)
141
+ * @property {number} pid - Process ID of the spawned child
142
+ * @property {Array<T | null>} output - Array containing stdout/stderr values
143
+ * @property {T} stdout - Standard output from the process
144
+ * @property {T} stderr - Standard error from the process
145
+ * @property {number | null} status - Exit code, or `null` if killed by signal
146
+ * @property {NodeJS.Signals | null} signal - Signal that terminated the process, or `null`
147
+ * @property {Error | undefined} error - Error object if the spawn failed
148
+ */
52
149
  export interface SpawnSyncReturns<T> {
53
150
  pid: number;
54
151
  output: Array<T | null>;
@@ -59,12 +156,42 @@ export interface SpawnSyncReturns<T> {
59
156
  error?: Error | undefined;
60
157
  }
61
158
  /**
62
- * Check if a value is a spawn error with expected properties.
159
+ * Check if a value is a spawn error with expected error properties.
160
+ * Tests for common error properties from child process failures.
161
+ *
162
+ * @param {unknown} value - Value to check
163
+ * @returns {boolean} `true` if the value has spawn error properties
164
+ *
165
+ * @example
166
+ * try {
167
+ * await spawn('nonexistent-command')
168
+ * } catch (error) {
169
+ * if (isSpawnError(error)) {
170
+ * console.error(`Spawn failed: ${error.code}`)
171
+ * }
172
+ * }
63
173
  */
64
174
  /*@__NO_SIDE_EFFECTS__*/
65
175
  export declare function isSpawnError(value: unknown): value is SpawnError;
66
176
  /**
67
177
  * Check if stdio configuration matches a specific type.
178
+ * When called with one argument, validates if it's a valid stdio type.
179
+ * When called with two arguments, checks if the stdio config matches the specified type.
180
+ *
181
+ * @param {string | string[]} stdio - Stdio configuration to check
182
+ * @param {StdioType | undefined} type - Expected stdio type (optional)
183
+ * @returns {boolean} `true` if stdio matches the type or is valid
184
+ *
185
+ * @example
186
+ * // Check if valid stdio type
187
+ * isStdioType('pipe') // true
188
+ * isStdioType('invalid') // false
189
+ *
190
+ * @example
191
+ * // Check if stdio matches specific type
192
+ * isStdioType('pipe', 'pipe') // true
193
+ * isStdioType(['pipe', 'pipe', 'pipe'], 'pipe') // true
194
+ * isStdioType('ignore', 'pipe') // false
68
195
  */
69
196
  /*@__NO_SIDE_EFFECTS__*/
70
197
  export declare function isStdioType(stdio: string | string[], type?: StdioType | undefined): boolean;
@@ -136,7 +263,20 @@ interface WritableStreamType {
136
263
  destroy(error?: Error | undefined): this;
137
264
  }
138
265
  /**
139
- * Spawn a child process with enhanced error handling and output capture.
266
+ * Options for spawning a child process with {@link spawn}.
267
+ * Extends Node.js spawn options with additional Socket-specific functionality.
268
+ *
269
+ * @property {import('./spinner').Spinner | undefined} spinner - Spinner instance to pause during execution
270
+ * @property {boolean | undefined} stdioString - Convert output to strings (default: `true`)
271
+ * @property {boolean | undefined} stripAnsi - Remove ANSI codes from output (default: `true`)
272
+ * @property {string | URL | undefined} cwd - Current working directory
273
+ * @property {NodeJS.ProcessEnv | undefined} env - Environment variables
274
+ * @property {StdioType | undefined} stdio - Stdio configuration
275
+ * @property {boolean | string | undefined} shell - Run command in shell
276
+ * @property {number | undefined} timeout - Timeout in milliseconds
277
+ * @property {AbortSignal | undefined} signal - Abort signal
278
+ * @property {number | undefined} uid - User identity (POSIX)
279
+ * @property {number | undefined} gid - Group identity (POSIX)
140
280
  */
141
281
  export type SpawnOptions = import('./objects').Remap<NodeSpawnOptions & {
142
282
  spinner?: import('./spinner').Spinner | undefined;
@@ -144,6 +284,16 @@ export type SpawnOptions = import('./objects').Remap<NodeSpawnOptions & {
144
284
  stripAnsi?: boolean;
145
285
  }>;
146
286
  export type SpawnResult = PromiseSpawnResult;
287
+ /**
288
+ * Result object returned when a spawned process completes.
289
+ *
290
+ * @property {string} cmd - Command that was executed
291
+ * @property {string[] | readonly string[]} args - Arguments passed to the command
292
+ * @property {number} code - Process exit code
293
+ * @property {NodeJS.Signals | null} signal - Signal that terminated the process, if any
294
+ * @property {string | Buffer} stdout - Standard output (string if `stdioString: true`, Buffer otherwise)
295
+ * @property {string | Buffer} stderr - Standard error (string if `stdioString: true`, Buffer otherwise)
296
+ */
147
297
  export type SpawnStdioResult = {
148
298
  cmd: string;
149
299
  args: string[] | readonly string[];
@@ -154,6 +304,7 @@ export type SpawnStdioResult = {
154
304
  };
155
305
  /**
156
306
  * Spawn a child process and return a promise that resolves when it completes.
307
+ * Provides enhanced error handling, output capture, and cross-platform support.
157
308
  *
158
309
  * SECURITY: This function uses array-based arguments which prevent command injection.
159
310
  * Arguments in the `args` array are passed directly to the OS without shell
@@ -164,26 +315,102 @@ export type SpawnStdioResult = {
164
315
  * approach remains secure because Node.js properly escapes each argument before passing
165
316
  * to the shell.
166
317
  *
167
- * @param cmd - Command to execute (not user-controlled)
168
- * @param args - Array of arguments (safe even with user input due to array-based passing)
169
- * @param options - Spawn options
170
- * @param extra - Extra options for promise-spawn
318
+ * @param {string} cmd - Command to execute (not user-controlled)
319
+ * @param {string[] | readonly string[] | undefined} args - Array of arguments (safe even with user input)
320
+ * @param {SpawnOptions | undefined} options - Spawn options for process configuration
321
+ * @param {SpawnExtra | undefined} extra - Extra options for promise-spawn
322
+ * @returns {SpawnResult} Promise that resolves with process exit information
323
+ *
324
+ * @throws {SpawnError} When the process exits with non-zero code or is terminated by signal
325
+ *
326
+ * @example
327
+ * // Basic usage - spawn and wait for completion
328
+ * const result = await spawn('git', ['status'])
329
+ * console.log(result.stdout)
330
+ *
331
+ * @example
332
+ * // With options - set working directory and environment
333
+ * const result = await spawn('npm', ['install'], {
334
+ * cwd: '/path/to/project',
335
+ * env: { NODE_ENV: 'production' }
336
+ * })
171
337
  *
172
338
  * @example
173
- * // ✔ DO THIS - Array-based arguments
339
+ * // ✔ DO THIS - Array-based arguments (safe)
174
340
  * spawn('git', ['commit', '-m', userMessage])
175
341
  * // Each argument is properly escaped, even if userMessage = "foo; rm -rf /"
176
342
  *
177
343
  * @example
178
- * // ✖ NEVER DO THIS - String concatenation
344
+ * // ✖ NEVER DO THIS - String concatenation (vulnerable)
179
345
  * spawn(`git commit -m "${userMessage}"`, { shell: true })
180
346
  * // Vulnerable to injection if userMessage = '"; rm -rf / #'
347
+ *
348
+ * @example
349
+ * // Access stdin for interactive processes
350
+ * const result = spawn('cat', [])
351
+ * result.stdin?.write('Hello\n')
352
+ * result.stdin?.end()
353
+ * const { stdout } = await result
354
+ * console.log(stdout) // 'Hello'
355
+ *
356
+ * @example
357
+ * // Handle errors with exit codes
358
+ * try {
359
+ * await spawn('exit', ['1'])
360
+ * } catch (error) {
361
+ * if (isSpawnError(error)) {
362
+ * console.error(`Failed with code ${error.code}`)
363
+ * console.error(error.stderr)
364
+ * }
365
+ * }
181
366
  */
182
367
  export declare function spawn(cmd: string, args?: string[] | readonly string[], options?: SpawnOptions | undefined, extra?: SpawnExtra | undefined): SpawnResult;
183
368
  /*@__NO_SIDE_EFFECTS__*/
184
369
  /**
185
- * Synchronously spawn a child process.
370
+ * Options for synchronously spawning a child process with {@link spawnSync}.
371
+ * Same as {@link SpawnOptions} but excludes the `spinner` property (not applicable for synchronous execution).
186
372
  */
187
373
  export type SpawnSyncOptions = Omit<SpawnOptions, 'spinner'>;
374
+ /**
375
+ * Synchronously spawn a child process and wait for it to complete.
376
+ * Blocks execution until the process exits, returning all output and exit information.
377
+ *
378
+ * WARNING: This function blocks the event loop. Use {@link spawn} for async operations.
379
+ *
380
+ * @param {string} cmd - Command to execute
381
+ * @param {string[] | readonly string[] | undefined} args - Array of arguments
382
+ * @param {SpawnSyncOptions | undefined} options - Spawn options for process configuration
383
+ * @returns {SpawnSyncReturns<string | Buffer>} Process result with exit code and captured output
384
+ *
385
+ * @example
386
+ * // Basic synchronous spawn
387
+ * const result = spawnSync('git', ['status'])
388
+ * console.log(result.stdout)
389
+ * console.log(result.status) // exit code
390
+ *
391
+ * @example
392
+ * // With options
393
+ * const result = spawnSync('npm', ['install'], {
394
+ * cwd: '/path/to/project',
395
+ * stdioString: true
396
+ * })
397
+ * if (result.status !== 0) {
398
+ * console.error(result.stderr)
399
+ * }
400
+ *
401
+ * @example
402
+ * // Get raw buffer output
403
+ * const result = spawnSync('cat', ['binary-file'], {
404
+ * stdioString: false
405
+ * })
406
+ * console.log(result.stdout) // Buffer
407
+ *
408
+ * @example
409
+ * // Handle process errors
410
+ * const result = spawnSync('nonexistent-command')
411
+ * if (result.error) {
412
+ * console.error('Failed to spawn:', result.error)
413
+ * }
414
+ */
188
415
  export declare function spawnSync(cmd: string, args?: string[] | readonly string[], options?: SpawnSyncOptions | undefined): SpawnSyncReturns<string | Buffer>;
189
416
  export {};
package/dist/spawn.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/spawn.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview Child process spawning utilities with cross-platform support.\n * Provides enhanced spawn functionality with stdio handling and error management.\n *\n * SECURITY: Array-Based Arguments Prevent Command Injection\n *\n * This module uses array-based arguments for all command execution, which is the\n * PRIMARY DEFENSE against command injection attacks. When you pass arguments as\n * an array to spawn():\n *\n * spawn('npx', ['sfw', tool, ...args], { shell: true })\n *\n * Node.js handles escaping automatically. Each argument is passed directly to the\n * OS without shell interpretation. Shell metacharacters like ; | & $ ( ) ` are\n * treated as LITERAL STRINGS, not as commands. This approach is secure even when\n * shell: true is used on Windows for .cmd/.bat file resolution.\n *\n * UNSAFE ALTERNATIVE (not used in this codebase):\n * spawn(`npx sfw ${tool} ${args.join(' ')}`, { shell: true }) // \u2716 VULNERABLE\n *\n * String concatenation allows injection. For example, if tool = \"foo; rm -rf /\",\n * the shell would execute both commands. Array-based arguments prevent this.\n *\n * References:\n * - https://nodejs.org/api/child_process.html#child_processspawncommand-args-options\n * - https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html\n */\n\nimport { getAbortSignal, getSpinner } from '#constants/process'\n\nimport { isArray } from './arrays'\n\nconst abortSignal = getAbortSignal()\nconst spinner = getSpinner()\n\nimport { getOwn, hasOwn } from './objects'\nimport { stripAnsi } from './strings'\n\n// Define BufferEncoding type for TypeScript compatibility.\ntype BufferEncoding = globalThis.BufferEncoding\n\nconst windowsScriptExtRegExp = /\\.(?:cmd|bat|ps1)$/i\n\nlet _child_process: typeof import('node:child_process') | undefined\n/**\n * Lazily load the child_process module.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getChildProcess() {\n if (_child_process === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _child_process = /*@__PURE__*/ require('node:child_process')\n }\n return _child_process as typeof import('node:child_process')\n}\n\n// Type for promise-spawn options.\nexport type PromiseSpawnOptions = {\n cwd?: string | undefined\n stdioString?: boolean | undefined\n stdio?: StdioType | undefined\n env?: NodeJS.ProcessEnv | undefined\n shell?: boolean | string | undefined\n signal?: AbortSignal | undefined\n timeout?: number | undefined\n uid?: number | undefined\n gid?: number | undefined\n}\n\n// Type for promise-spawn result.\nexport type PromiseSpawnResult = Promise<{\n cmd: string\n args: string[] | readonly string[]\n code: number\n signal: NodeJS.Signals | null\n stdout: string | Buffer\n stderr: string | Buffer\n}> & {\n process: ChildProcessType\n stdin: WritableStreamType | null\n}\n\nlet _npmCliPromiseSpawn:\n | ((\n cmd: string,\n args: string[],\n options?: PromiseSpawnOptions | undefined,\n extra?: SpawnExtra | undefined,\n ) => PromiseSpawnResult)\n | undefined\n/**\n * Lazily load the promise-spawn module for async process spawning.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getNpmcliPromiseSpawn() {\n if (_npmCliPromiseSpawn === undefined) {\n _npmCliPromiseSpawn = /*@__PURE__*/ require('./external/@npmcli/promise-spawn')\n }\n return _npmCliPromiseSpawn as unknown as typeof import('@npmcli/promise-spawn')\n}\n\nlet _path: typeof import('node:path') | undefined\n/**\n * Lazily load the path module to avoid Webpack errors.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getPath() {\n if (_path === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _path = /*@__PURE__*/ require('node:path')\n }\n return _path as typeof import('node:path')\n}\n\n/**\n * Check if a value is a spawn error.\n */\nexport type SpawnError = {\n args: string[]\n cmd: string\n code: number\n name: string\n message: string\n signal: NodeJS.Signals | null\n stack: string\n stderr: string | Buffer\n stdout: string | Buffer\n}\n\nexport type SpawnErrorWithOutputString = SpawnError & {\n stdout: string\n stderr: string\n}\n\nexport type SpawnErrorWithOutputBuffer = SpawnError & {\n stdout: Buffer\n stderr: Buffer\n}\n\nexport type SpawnExtra = Record<string, unknown>\n\nexport type IOType = 'pipe' | 'ignore' | 'inherit' | 'overlapped'\nexport type StdioType = IOType | 'ipc' | Array<IOType | 'ipc'>\n\nexport interface SpawnSyncReturns<T> {\n pid: number\n output: Array<T | null>\n stdout: T\n stderr: T\n status: number | null\n signal: NodeJS.Signals | null\n error?: Error | undefined\n}\n\n/**\n * Check if a value is a spawn error with expected properties.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isSpawnError(value: unknown): value is SpawnError {\n if (value === null || typeof value !== 'object') {\n return false\n }\n // Check for spawn-specific error properties.\n const err = value as Record<string, unknown>\n return (\n (hasOwn(err, 'code') && typeof err['code'] !== 'undefined') ||\n (hasOwn(err, 'errno') && typeof err['errno'] !== 'undefined') ||\n (hasOwn(err, 'syscall') && typeof err['syscall'] === 'string')\n )\n}\n\n/**\n * Check if stdio configuration matches a specific type.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isStdioType(\n stdio: string | string[],\n type?: StdioType | undefined,\n): boolean {\n // If called with one argument, check if it's a valid stdio type.\n // biome-ignore lint/complexity/noArguments: Function overload detection for single vs two-arg calls.\n if (arguments.length === 1) {\n const validTypes = ['pipe', 'ignore', 'inherit', 'overlapped']\n return typeof stdio === 'string' && validTypes.includes(stdio)\n }\n // Original two-argument behavior.\n return (\n stdio === type ||\n ((stdio === null || stdio === undefined) && type === 'pipe') ||\n (isArray(stdio) &&\n stdio.length > 2 &&\n stdio[0] === type &&\n stdio[1] === type &&\n stdio[2] === type)\n )\n}\n\n/**\n * Strip ANSI escape codes from spawn result stdout and stderr.\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction stripAnsiFromSpawnResult(result: unknown): unknown {\n const res = result as {\n stdout?: string | Buffer\n stderr?: string | Buffer\n }\n const { stderr, stdout } = res\n if (typeof stdout === 'string') {\n res.stdout = stripAnsi(stdout)\n }\n if (typeof stderr === 'string') {\n res.stderr = stripAnsi(stderr)\n }\n return res\n}\n\n/*@__NO_SIDE_EFFECTS__*/\n// Duplicated from Node.js child_process.SpawnOptions\n// These are the options passed to child_process.spawn()\ninterface NodeSpawnOptions {\n cwd?: string | URL | undefined\n env?: NodeJS.ProcessEnv | undefined\n argv0?: string | undefined\n stdio?: any\n detached?: boolean | undefined\n uid?: number | undefined\n gid?: number | undefined\n serialization?: 'json' | 'advanced' | undefined\n shell?: boolean | string | undefined\n windowsVerbatimArguments?: boolean | undefined\n windowsHide?: boolean | undefined\n signal?: AbortSignal | undefined\n timeout?: number | undefined\n killSignal?: NodeJS.Signals | number | undefined\n}\n\n// Duplicated from Node.js child_process.ChildProcess\n// This represents a spawned child process\ninterface ChildProcessType {\n stdin: NodeJS.WritableStream | null\n stdout: NodeJS.ReadableStream | null\n stderr: NodeJS.ReadableStream | null\n readonly channel?: any\n readonly stdio: [\n NodeJS.WritableStream | null,\n NodeJS.ReadableStream | null,\n NodeJS.ReadableStream | null,\n NodeJS.ReadableStream | NodeJS.WritableStream | null | undefined,\n NodeJS.ReadableStream | NodeJS.WritableStream | null | undefined,\n ]\n readonly killed: boolean\n readonly pid?: number | undefined\n readonly connected: boolean\n readonly exitCode: number | null\n readonly signalCode: NodeJS.Signals | null\n readonly spawnargs: string[]\n readonly spawnfile: string\n kill(signal?: NodeJS.Signals | number): boolean\n send(message: any, callback?: (error: Error | null) => void): boolean\n send(\n message: any,\n sendHandle?: any | undefined,\n callback?: (error: Error | null) => void,\n ): boolean\n send(\n message: any,\n sendHandle?: any | undefined,\n options?: any | undefined,\n callback?: (error: Error | null) => void,\n ): boolean\n disconnect(): void\n unref(): void\n ref(): void\n}\n\n// Duplicated from Node.js stream.Writable\ninterface WritableStreamType {\n writable: boolean\n writableEnded: boolean\n writableFinished: boolean\n writableHighWaterMark: number\n writableLength: number\n writableObjectMode: boolean\n writableCorked: number\n destroyed: boolean\n write(\n chunk: any,\n encoding?: BufferEncoding | undefined,\n callback?: (error?: Error | null) => void,\n ): boolean\n write(chunk: any, callback?: (error?: Error | null) => void): boolean\n end(cb?: () => void): this\n end(chunk: any, cb?: () => void): this\n end(chunk: any, encoding?: BufferEncoding | undefined, cb?: () => void): this\n cork(): void\n uncork(): void\n destroy(error?: Error | undefined): this\n}\n\n/**\n * Spawn a child process with enhanced error handling and output capture.\n */\nexport type SpawnOptions = import('./objects').Remap<\n NodeSpawnOptions & {\n spinner?: import('./spinner').Spinner | undefined\n stdioString?: boolean\n stripAnsi?: boolean\n }\n>\nexport type SpawnResult = PromiseSpawnResult\nexport type SpawnStdioResult = {\n cmd: string\n args: string[] | readonly string[]\n code: number\n signal: NodeJS.Signals | null\n stdout: string | Buffer\n stderr: string | Buffer\n}\n\n/**\n * Spawn a child process and return a promise that resolves when it completes.\n *\n * SECURITY: This function uses array-based arguments which prevent command injection.\n * Arguments in the `args` array are passed directly to the OS without shell\n * interpretation. Shell metacharacters (;|&$()`) are treated as literal strings,\n * not as commands or operators. This is the PRIMARY SECURITY DEFENSE.\n *\n * Even when shell: true is used (on Windows for .cmd/.bat execution), the array-based\n * approach remains secure because Node.js properly escapes each argument before passing\n * to the shell.\n *\n * @param cmd - Command to execute (not user-controlled)\n * @param args - Array of arguments (safe even with user input due to array-based passing)\n * @param options - Spawn options\n * @param extra - Extra options for promise-spawn\n *\n * @example\n * // \u2714 DO THIS - Array-based arguments\n * spawn('git', ['commit', '-m', userMessage])\n * // Each argument is properly escaped, even if userMessage = \"foo; rm -rf /\"\n *\n * @example\n * // \u2716 NEVER DO THIS - String concatenation\n * spawn(`git commit -m \"${userMessage}\"`, { shell: true })\n * // Vulnerable to injection if userMessage = '\"; rm -rf / #'\n */\nexport function spawn(\n cmd: string,\n args?: string[] | readonly string[],\n options?: SpawnOptions | undefined,\n extra?: SpawnExtra | undefined,\n): SpawnResult {\n // Windows cmd.exe command resolution for .cmd/.bat/.ps1 files:\n //\n // When shell: true is used on Windows with script files (.cmd, .bat, .ps1),\n // cmd.exe can have issues executing full paths. The solution is to use just\n // the command basename without extension and let cmd.exe find it via PATH.\n //\n // How cmd.exe resolves commands:\n // 1. Searches current directory first\n // 2. Then searches each directory in PATH environment variable\n // 3. For each directory, tries extensions from PATHEXT (.COM, .EXE, .BAT, .CMD, etc.)\n // 4. Executes the first match found\n //\n // Example: Given 'C:\\pnpm\\pnpm.cmd' with shell: true\n // 1. Extract basename without extension: 'pnpm'\n // 2. cmd.exe searches PATH directories for 'pnpm'\n // 3. PATHEXT causes it to try 'pnpm.com', 'pnpm.exe', 'pnpm.bat', 'pnpm.cmd', etc.\n // 4. Finds and executes 'C:\\pnpm\\pnpm.cmd'\n //\n // This approach is consistent with how other tools handle Windows execution:\n // - npm's promise-spawn: uses which.sync() to find commands in PATH\n // - cross-spawn: spawns cmd.exe with escaped arguments\n // - execa: uses cross-spawn under the hood for Windows support\n //\n // See: https://github.com/nodejs/node/issues/3675\n const shell = getOwn(options, 'shell')\n // Inline WIN32 constant for coverage mode compatibility\n const WIN32 = process.platform === 'win32'\n let actualCmd = cmd\n if (WIN32 && shell && windowsScriptExtRegExp.test(actualCmd)) {\n const path = getPath()\n // Extract just the command name without path and extension.\n actualCmd = path.basename(actualCmd, path.extname(actualCmd))\n }\n const {\n spinner: optionsSpinner = spinner,\n stripAnsi: shouldStripAnsi = true,\n ...spawnOptions\n } = { __proto__: null, ...options } as SpawnOptions\n const spinnerInstance = optionsSpinner\n const { env, stdio, stdioString = true } = spawnOptions\n // The stdio option can be a string or an array.\n // https://nodejs.org/api/child_process.html#optionsstdio\n const wasSpinning = !!spinnerInstance?.isSpinning\n const shouldStopSpinner =\n wasSpinning && !isStdioType(stdio, 'ignore') && !isStdioType(stdio, 'pipe')\n const shouldRestartSpinner = shouldStopSpinner\n if (shouldStopSpinner) {\n spinnerInstance.stop()\n }\n const npmCliPromiseSpawn = getNpmcliPromiseSpawn()\n // Use __proto__: null to prevent prototype pollution when passing to\n // third-party code, Node.js built-ins, or JavaScript built-in methods.\n // https://github.com/npm/promise-spawn\n // https://github.com/nodejs/node/blob/v24.0.1/lib/child_process.js#L674-L678\n const promiseSpawnOpts = {\n __proto__: null,\n cwd: typeof spawnOptions.cwd === 'string' ? spawnOptions.cwd : undefined,\n env: {\n __proto__: null,\n ...process.env,\n ...env,\n } as unknown as NodeJS.ProcessEnv,\n signal: abortSignal,\n stdio: spawnOptions.stdio,\n stdioString,\n shell: spawnOptions.shell,\n timeout: spawnOptions.timeout,\n uid: spawnOptions.uid,\n gid: spawnOptions.gid,\n } as unknown as PromiseSpawnOptions\n const spawnPromise = npmCliPromiseSpawn(\n actualCmd,\n args ? [...args] : [],\n promiseSpawnOpts as Parameters<typeof npmCliPromiseSpawn>[2],\n extra,\n )\n const oldSpawnPromise = spawnPromise\n let newSpawnPromise: PromiseSpawnResult\n if (shouldStripAnsi && stdioString) {\n newSpawnPromise = spawnPromise\n .then(result => {\n const strippedResult = stripAnsiFromSpawnResult(result)\n // Add exitCode as an alias for code.\n if ('code' in (strippedResult as { code?: number })) {\n ;(strippedResult as { code: number; exitCode: number }).exitCode = (\n strippedResult as { code: number }\n ).code\n }\n return strippedResult\n })\n .catch(error => {\n throw stripAnsiFromSpawnResult(error)\n }) as PromiseSpawnResult\n } else {\n newSpawnPromise = spawnPromise.then(result => {\n // Add exitCode as an alias for code.\n if ('code' in result) {\n const res = result as typeof result & { exitCode: number }\n res.exitCode = result.code\n return res\n }\n return result\n }) as PromiseSpawnResult\n }\n if (shouldRestartSpinner) {\n newSpawnPromise = newSpawnPromise.finally(() => {\n spinnerInstance.start()\n }) as PromiseSpawnResult\n }\n // Copy process and stdin properties from original promise\n ;(newSpawnPromise as unknown as PromiseSpawnResult).process =\n oldSpawnPromise.process\n ;(newSpawnPromise as unknown as PromiseSpawnResult).stdin = (\n oldSpawnPromise as unknown as PromiseSpawnResult\n ).stdin\n return newSpawnPromise as SpawnResult\n}\n\n/*@__NO_SIDE_EFFECTS__*/\n/**\n * Synchronously spawn a child process.\n */\nexport type SpawnSyncOptions = Omit<SpawnOptions, 'spinner'>\nexport function spawnSync(\n cmd: string,\n args?: string[] | readonly string[],\n options?: SpawnSyncOptions | undefined,\n): SpawnSyncReturns<string | Buffer> {\n // Windows cmd.exe command resolution for .cmd/.bat/.ps1 files:\n // See spawn() function above for detailed explanation of this approach.\n const shell = getOwn(options, 'shell')\n // Inline WIN32 constant for coverage mode compatibility\n const WIN32 = process.platform === 'win32'\n let actualCmd = cmd\n if (WIN32 && shell && windowsScriptExtRegExp.test(actualCmd)) {\n const path = getPath()\n // Extract just the command name without path and extension.\n actualCmd = path.basename(actualCmd, path.extname(actualCmd))\n }\n const { stripAnsi: shouldStripAnsi = true, ...rawSpawnOptions } = {\n __proto__: null,\n ...options,\n } as SpawnSyncOptions\n const { stdioString: rawStdioString = true } = rawSpawnOptions\n const rawEncoding = rawStdioString ? 'utf8' : 'buffer'\n const spawnOptions = {\n encoding: rawEncoding,\n ...rawSpawnOptions,\n } as NodeSpawnOptions & { encoding: BufferEncoding | 'buffer' }\n const stdioString = spawnOptions.encoding !== 'buffer'\n const result = getChildProcess().spawnSync(actualCmd, args, spawnOptions)\n if (stdioString) {\n const { stderr, stdout } = result\n if (stdout) {\n result.stdout = stdout.toString().trim()\n }\n if (stderr) {\n result.stderr = stderr.toString().trim()\n }\n }\n return (\n shouldStripAnsi && stdioString ? stripAnsiFromSpawnResult(result) : result\n ) as SpawnSyncReturns<string | Buffer>\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BA,qBAA2C;AAE3C,oBAAwB;AAKxB,qBAA+B;AAC/B,qBAA0B;AAJ1B,MAAM,kBAAc,+BAAe;AACnC,MAAM,cAAU,2BAAW;AAQ3B,MAAM,yBAAyB;AAE/B,IAAI;AAAA;AAKJ,SAAS,kBAAkB;AACzB,MAAI,mBAAmB,QAAW;AAGhC,qBAA+B,QAAQ,oBAAoB;AAAA,EAC7D;AACA,SAAO;AACT;AA4BA,IAAI;AAAA;AAYJ,SAAS,wBAAwB;AAC/B,MAAI,wBAAwB,QAAW;AACrC,0BAAoC,QAAQ,kCAAkC;AAAA,EAChF;AACA,SAAO;AACT;AAEA,IAAI;AAAA;AAKJ,SAAS,UAAU;AACjB,MAAI,UAAU,QAAW;AAGvB,YAAsB,QAAQ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,MAAM;AACZ,YAAI,WAAW,OAAO;AACtB,eAAO;AAAA,MACT;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AACA,MAAI,sBAAsB;AACxB,sBAAkB,gBAAgB,QAAQ,MAAM;AAC9C,sBAAgB,MAAM;AAAA,IACxB,CAAC;AAAA,EACH;AAEA;AAAC,EAAC,gBAAkD,UAClD,gBAAgB;AACjB,EAAC,gBAAkD,QAClD,gBACA;AACF,SAAO;AACT;AAOO,SAAS,UACd,KACA,MACA,SACmC;AAGnC,QAAM,YAAQ,uBAAO,SAAS,OAAO;AAErC,QAAM,QAAQ,QAAQ,aAAa;AACnC,MAAI,YAAY;AAChB,MAAI,SAAS,SAAS,uBAAuB,KAAK,SAAS,GAAG;AAC5D,UAAM,OAAO,wBAAQ;AAErB,gBAAY,KAAK,SAAS,WAAW,KAAK,QAAQ,SAAS,CAAC;AAAA,EAC9D;AACA,QAAM,EAAE,WAAW,kBAAkB,MAAM,GAAG,gBAAgB,IAAI;AAAA,IAChE,WAAW;AAAA,IACX,GAAG;AAAA,EACL;AACA,QAAM,EAAE,aAAa,iBAAiB,KAAK,IAAI;AAC/C,QAAM,cAAc,iBAAiB,SAAS;AAC9C,QAAM,eAAe;AAAA,IACnB,UAAU;AAAA,IACV,GAAG;AAAA,EACL;AACA,QAAM,cAAc,aAAa,aAAa;AAC9C,QAAM,UAAS,gCAAgB,GAAE,UAAU,WAAW,MAAM,YAAY;AACxE,MAAI,aAAa;AACf,UAAM,EAAE,QAAQ,OAAO,IAAI;AAC3B,QAAI,QAAQ;AACV,aAAO,SAAS,OAAO,SAAS,EAAE,KAAK;AAAA,IACzC;AACA,QAAI,QAAQ;AACV,aAAO,SAAS,OAAO,SAAS,EAAE,KAAK;AAAA,IACzC;AAAA,EACF;AACA,SACE,mBAAmB,cAAc,yCAAyB,MAAM,IAAI;AAExE;",
4
+ "sourcesContent": ["/**\n * @fileoverview Child process spawning utilities with cross-platform support.\n * Provides enhanced spawn functionality with stdio handling and error management.\n *\n * SECURITY: Array-Based Arguments Prevent Command Injection\n *\n * This module uses array-based arguments for all command execution, which is the\n * PRIMARY DEFENSE against command injection attacks. When you pass arguments as\n * an array to spawn():\n *\n * spawn('npx', ['sfw', tool, ...args], { shell: true })\n *\n * Node.js handles escaping automatically. Each argument is passed directly to the\n * OS without shell interpretation. Shell metacharacters like ; | & $ ( ) ` are\n * treated as LITERAL STRINGS, not as commands. This approach is secure even when\n * shell: true is used on Windows for .cmd/.bat file resolution.\n *\n * UNSAFE ALTERNATIVE (not used in this codebase):\n * spawn(`npx sfw ${tool} ${args.join(' ')}`, { shell: true }) // \u2716 VULNERABLE\n *\n * String concatenation allows injection. For example, if tool = \"foo; rm -rf /\",\n * the shell would execute both commands. Array-based arguments prevent this.\n *\n * References:\n * - https://nodejs.org/api/child_process.html#child_processspawncommand-args-options\n * - https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html\n */\n\nimport { getAbortSignal, getSpinner } from '#constants/process'\n\nimport { isArray } from './arrays'\n\nconst abortSignal = getAbortSignal()\nconst spinner = getSpinner()\n\nimport { getOwn, hasOwn } from './objects'\nimport { stripAnsi } from './strings'\n\n// Define BufferEncoding type for TypeScript compatibility.\ntype BufferEncoding = globalThis.BufferEncoding\n\nconst windowsScriptExtRegExp = /\\.(?:cmd|bat|ps1)$/i\n\nlet _child_process: typeof import('node:child_process') | undefined\n/**\n * Lazily load the `child_process` module to avoid Webpack bundling issues.\n *\n * @returns The Node.js `child_process` module\n *\n * @example\n * const childProcess = getChildProcess()\n * childProcess.spawnSync('ls', ['-la'])\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getChildProcess() {\n if (_child_process === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _child_process = /*@__PURE__*/ require('node:child_process')\n }\n return _child_process as typeof import('node:child_process')\n}\n\n/**\n * Options for spawning a child process with promise-based completion.\n *\n * @property {string | undefined} cwd - Current working directory for the process\n * @property {boolean | undefined} stdioString - Convert stdio output to strings (default: `true`)\n * @property {StdioType | undefined} stdio - Stdio configuration (`'pipe'`, `'ignore'`, `'inherit'`, or array)\n * @property {NodeJS.ProcessEnv | undefined} env - Environment variables for the process\n * @property {boolean | string | undefined} shell - Whether to run command in shell, or path to shell\n * @property {AbortSignal | undefined} signal - Signal to abort the process\n * @property {number | undefined} timeout - Maximum time in milliseconds before killing the process\n * @property {number | undefined} uid - User identity of the process (POSIX only)\n * @property {number | undefined} gid - Group identity of the process (POSIX only)\n */\nexport type PromiseSpawnOptions = {\n cwd?: string | undefined\n stdioString?: boolean | undefined\n stdio?: StdioType | undefined\n env?: NodeJS.ProcessEnv | undefined\n shell?: boolean | string | undefined\n signal?: AbortSignal | undefined\n timeout?: number | undefined\n uid?: number | undefined\n gid?: number | undefined\n}\n\n/**\n * Result returned by {@link spawn} when the child process completes.\n * This is a Promise that resolves with process exit information and output,\n * with additional properties for accessing the running process and stdin stream.\n *\n * @property {ChildProcessType} process - The running child process instance\n * @property {WritableStreamType | null} stdin - Writable stream for process stdin, or `null` if not piped\n *\n * @example\n * const result = spawn('echo', ['hello'])\n * result.stdin?.write('additional input\\n')\n * const { code, stdout } = await result\n * console.log(stdout) // 'hello'\n */\nexport type PromiseSpawnResult = Promise<{\n cmd: string\n args: string[] | readonly string[]\n code: number\n signal: NodeJS.Signals | null\n stdout: string | Buffer\n stderr: string | Buffer\n}> & {\n process: ChildProcessType\n stdin: WritableStreamType | null\n}\n\nlet _npmCliPromiseSpawn:\n | ((\n cmd: string,\n args: string[],\n options?: PromiseSpawnOptions | undefined,\n extra?: SpawnExtra | undefined,\n ) => PromiseSpawnResult)\n | undefined\n/**\n * Lazily load the `@npmcli/promise-spawn` module for async process spawning.\n *\n * @returns The promise-spawn module that provides Promise-based spawn functionality\n *\n * @example\n * const promiseSpawn = getNpmcliPromiseSpawn()\n * await promiseSpawn('git', ['status'])\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getNpmcliPromiseSpawn() {\n if (_npmCliPromiseSpawn === undefined) {\n _npmCliPromiseSpawn = /*@__PURE__*/ require('./external/@npmcli/promise-spawn')\n }\n return _npmCliPromiseSpawn as unknown as typeof import('@npmcli/promise-spawn')\n}\n\nlet _path: typeof import('node:path') | undefined\n/**\n * Lazily load the `path` module to avoid Webpack bundling issues.\n *\n * @returns The Node.js `path` module\n *\n * @example\n * const path = getPath()\n * const basename = path.basename('/foo/bar.txt')\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction getPath() {\n if (_path === undefined) {\n // Use non-'node:' prefixed require to avoid Webpack errors.\n\n _path = /*@__PURE__*/ require('node:path')\n }\n return _path as typeof import('node:path')\n}\n\n/**\n * Error object thrown when a spawned process fails.\n * Extends the standard Error with process-specific information including exit code,\n * signal, command details, and captured output.\n *\n * @property {string[]} args - Arguments passed to the command\n * @property {string} cmd - Command that was executed\n * @property {number} code - Process exit code\n * @property {string} name - Error name (typically `'Error'`)\n * @property {string} message - Error message describing the failure\n * @property {NodeJS.Signals | null} signal - Signal that terminated the process, if any\n * @property {string} stack - Stack trace of the error\n * @property {string | Buffer} stderr - Standard error output from the process\n * @property {string | Buffer} stdout - Standard output from the process\n *\n * @example\n * try {\n * await spawn('exit', ['1'])\n * } catch (error) {\n * if (isSpawnError(error)) {\n * console.error(`Command failed with code ${error.code}`)\n * console.error(`stderr: ${error.stderr}`)\n * }\n * }\n */\nexport type SpawnError = {\n args: string[]\n cmd: string\n code: number\n name: string\n message: string\n signal: NodeJS.Signals | null\n stack: string\n stderr: string | Buffer\n stdout: string | Buffer\n}\n\n/**\n * Spawn error variant where stdout and stderr are guaranteed to be strings.\n * This type is used when `stdioString: true` is set in spawn options.\n *\n * @property {string} stdout - Standard output as a string\n * @property {string} stderr - Standard error as a string\n */\nexport type SpawnErrorWithOutputString = SpawnError & {\n stdout: string\n stderr: string\n}\n\n/**\n * Spawn error variant where stdout and stderr are guaranteed to be Buffers.\n * This type is used when `stdioString: false` is set in spawn options.\n *\n * @property {Buffer} stdout - Standard output as a Buffer\n * @property {Buffer} stderr - Standard error as a Buffer\n */\nexport type SpawnErrorWithOutputBuffer = SpawnError & {\n stdout: Buffer\n stderr: Buffer\n}\n\n/**\n * Extra options passed to the underlying promise-spawn implementation.\n * This is an open-ended object for passing additional metadata or configuration.\n */\nexport type SpawnExtra = Record<string, unknown>\n\n/**\n * Valid values for individual stdio streams.\n * - `'pipe'` - Creates a pipe between child and parent (default)\n * - `'ignore'` - Ignores the stream\n * - `'inherit'` - Uses parent's stream\n * - `'overlapped'` - Windows-specific overlapped I/O\n */\nexport type IOType = 'pipe' | 'ignore' | 'inherit' | 'overlapped'\n\n/**\n * Configuration for process stdio (stdin, stdout, stderr) streams.\n * Can be a single value applied to all streams, or an array specifying each stream individually.\n * - `'ipc'` - Creates an IPC channel for communication with the parent\n *\n * @example\n * // All streams piped\n * stdio: 'pipe'\n *\n * @example\n * // Custom configuration per stream: [stdin, stdout, stderr]\n * stdio: ['ignore', 'pipe', 'pipe']\n */\nexport type StdioType = IOType | 'ipc' | Array<IOType | 'ipc'>\n\n/**\n * Result object returned by {@link spawnSync} when the child process completes synchronously.\n *\n * @template T - Type of stdout/stderr (string or Buffer)\n * @property {number} pid - Process ID of the spawned child\n * @property {Array<T | null>} output - Array containing stdout/stderr values\n * @property {T} stdout - Standard output from the process\n * @property {T} stderr - Standard error from the process\n * @property {number | null} status - Exit code, or `null` if killed by signal\n * @property {NodeJS.Signals | null} signal - Signal that terminated the process, or `null`\n * @property {Error | undefined} error - Error object if the spawn failed\n */\nexport interface SpawnSyncReturns<T> {\n pid: number\n output: Array<T | null>\n stdout: T\n stderr: T\n status: number | null\n signal: NodeJS.Signals | null\n error?: Error | undefined\n}\n\n/**\n * Check if a value is a spawn error with expected error properties.\n * Tests for common error properties from child process failures.\n *\n * @param {unknown} value - Value to check\n * @returns {boolean} `true` if the value has spawn error properties\n *\n * @example\n * try {\n * await spawn('nonexistent-command')\n * } catch (error) {\n * if (isSpawnError(error)) {\n * console.error(`Spawn failed: ${error.code}`)\n * }\n * }\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isSpawnError(value: unknown): value is SpawnError {\n if (value === null || typeof value !== 'object') {\n return false\n }\n // Check for spawn-specific error properties.\n const err = value as Record<string, unknown>\n return (\n (hasOwn(err, 'code') && typeof err['code'] !== 'undefined') ||\n (hasOwn(err, 'errno') && typeof err['errno'] !== 'undefined') ||\n (hasOwn(err, 'syscall') && typeof err['syscall'] === 'string')\n )\n}\n\n/**\n * Check if stdio configuration matches a specific type.\n * When called with one argument, validates if it's a valid stdio type.\n * When called with two arguments, checks if the stdio config matches the specified type.\n *\n * @param {string | string[]} stdio - Stdio configuration to check\n * @param {StdioType | undefined} type - Expected stdio type (optional)\n * @returns {boolean} `true` if stdio matches the type or is valid\n *\n * @example\n * // Check if valid stdio type\n * isStdioType('pipe') // true\n * isStdioType('invalid') // false\n *\n * @example\n * // Check if stdio matches specific type\n * isStdioType('pipe', 'pipe') // true\n * isStdioType(['pipe', 'pipe', 'pipe'], 'pipe') // true\n * isStdioType('ignore', 'pipe') // false\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function isStdioType(\n stdio: string | string[],\n type?: StdioType | undefined,\n): boolean {\n // If called with one argument, check if it's a valid stdio type.\n // biome-ignore lint/complexity/noArguments: Function overload detection for single vs two-arg calls.\n if (arguments.length === 1) {\n const validTypes = ['pipe', 'ignore', 'inherit', 'overlapped']\n return typeof stdio === 'string' && validTypes.includes(stdio)\n }\n // Original two-argument behavior.\n return (\n stdio === type ||\n ((stdio === null || stdio === undefined) && type === 'pipe') ||\n (isArray(stdio) &&\n stdio.length > 2 &&\n stdio[0] === type &&\n stdio[1] === type &&\n stdio[2] === type)\n )\n}\n\n/**\n * Strip ANSI escape codes from spawn result stdout and stderr.\n * Modifies the result object in place to remove color codes and formatting.\n *\n * @param {unknown} result - Spawn result object with stdout/stderr properties\n * @returns {unknown} The modified result object\n */\n/*@__NO_SIDE_EFFECTS__*/\nfunction stripAnsiFromSpawnResult(result: unknown): unknown {\n const res = result as {\n stdout?: string | Buffer\n stderr?: string | Buffer\n }\n const { stderr, stdout } = res\n if (typeof stdout === 'string') {\n res.stdout = stripAnsi(stdout)\n }\n if (typeof stderr === 'string') {\n res.stderr = stripAnsi(stderr)\n }\n return res\n}\n\n/*@__NO_SIDE_EFFECTS__*/\n// Duplicated from Node.js child_process.SpawnOptions\n// These are the options passed to child_process.spawn()\ninterface NodeSpawnOptions {\n cwd?: string | URL | undefined\n env?: NodeJS.ProcessEnv | undefined\n argv0?: string | undefined\n stdio?: any\n detached?: boolean | undefined\n uid?: number | undefined\n gid?: number | undefined\n serialization?: 'json' | 'advanced' | undefined\n shell?: boolean | string | undefined\n windowsVerbatimArguments?: boolean | undefined\n windowsHide?: boolean | undefined\n signal?: AbortSignal | undefined\n timeout?: number | undefined\n killSignal?: NodeJS.Signals | number | undefined\n}\n\n// Duplicated from Node.js child_process.ChildProcess\n// This represents a spawned child process\ninterface ChildProcessType {\n stdin: NodeJS.WritableStream | null\n stdout: NodeJS.ReadableStream | null\n stderr: NodeJS.ReadableStream | null\n readonly channel?: any\n readonly stdio: [\n NodeJS.WritableStream | null,\n NodeJS.ReadableStream | null,\n NodeJS.ReadableStream | null,\n NodeJS.ReadableStream | NodeJS.WritableStream | null | undefined,\n NodeJS.ReadableStream | NodeJS.WritableStream | null | undefined,\n ]\n readonly killed: boolean\n readonly pid?: number | undefined\n readonly connected: boolean\n readonly exitCode: number | null\n readonly signalCode: NodeJS.Signals | null\n readonly spawnargs: string[]\n readonly spawnfile: string\n kill(signal?: NodeJS.Signals | number): boolean\n send(message: any, callback?: (error: Error | null) => void): boolean\n send(\n message: any,\n sendHandle?: any | undefined,\n callback?: (error: Error | null) => void,\n ): boolean\n send(\n message: any,\n sendHandle?: any | undefined,\n options?: any | undefined,\n callback?: (error: Error | null) => void,\n ): boolean\n disconnect(): void\n unref(): void\n ref(): void\n}\n\n// Duplicated from Node.js stream.Writable\ninterface WritableStreamType {\n writable: boolean\n writableEnded: boolean\n writableFinished: boolean\n writableHighWaterMark: number\n writableLength: number\n writableObjectMode: boolean\n writableCorked: number\n destroyed: boolean\n write(\n chunk: any,\n encoding?: BufferEncoding | undefined,\n callback?: (error?: Error | null) => void,\n ): boolean\n write(chunk: any, callback?: (error?: Error | null) => void): boolean\n end(cb?: () => void): this\n end(chunk: any, cb?: () => void): this\n end(chunk: any, encoding?: BufferEncoding | undefined, cb?: () => void): this\n cork(): void\n uncork(): void\n destroy(error?: Error | undefined): this\n}\n\n/**\n * Options for spawning a child process with {@link spawn}.\n * Extends Node.js spawn options with additional Socket-specific functionality.\n *\n * @property {import('./spinner').Spinner | undefined} spinner - Spinner instance to pause during execution\n * @property {boolean | undefined} stdioString - Convert output to strings (default: `true`)\n * @property {boolean | undefined} stripAnsi - Remove ANSI codes from output (default: `true`)\n * @property {string | URL | undefined} cwd - Current working directory\n * @property {NodeJS.ProcessEnv | undefined} env - Environment variables\n * @property {StdioType | undefined} stdio - Stdio configuration\n * @property {boolean | string | undefined} shell - Run command in shell\n * @property {number | undefined} timeout - Timeout in milliseconds\n * @property {AbortSignal | undefined} signal - Abort signal\n * @property {number | undefined} uid - User identity (POSIX)\n * @property {number | undefined} gid - Group identity (POSIX)\n */\nexport type SpawnOptions = import('./objects').Remap<\n NodeSpawnOptions & {\n spinner?: import('./spinner').Spinner | undefined\n stdioString?: boolean\n stripAnsi?: boolean\n }\n>\nexport type SpawnResult = PromiseSpawnResult\n/**\n * Result object returned when a spawned process completes.\n *\n * @property {string} cmd - Command that was executed\n * @property {string[] | readonly string[]} args - Arguments passed to the command\n * @property {number} code - Process exit code\n * @property {NodeJS.Signals | null} signal - Signal that terminated the process, if any\n * @property {string | Buffer} stdout - Standard output (string if `stdioString: true`, Buffer otherwise)\n * @property {string | Buffer} stderr - Standard error (string if `stdioString: true`, Buffer otherwise)\n */\nexport type SpawnStdioResult = {\n cmd: string\n args: string[] | readonly string[]\n code: number\n signal: NodeJS.Signals | null\n stdout: string | Buffer\n stderr: string | Buffer\n}\n\n/**\n * Spawn a child process and return a promise that resolves when it completes.\n * Provides enhanced error handling, output capture, and cross-platform support.\n *\n * SECURITY: This function uses array-based arguments which prevent command injection.\n * Arguments in the `args` array are passed directly to the OS without shell\n * interpretation. Shell metacharacters (;|&$()`) are treated as literal strings,\n * not as commands or operators. This is the PRIMARY SECURITY DEFENSE.\n *\n * Even when shell: true is used (on Windows for .cmd/.bat execution), the array-based\n * approach remains secure because Node.js properly escapes each argument before passing\n * to the shell.\n *\n * @param {string} cmd - Command to execute (not user-controlled)\n * @param {string[] | readonly string[] | undefined} args - Array of arguments (safe even with user input)\n * @param {SpawnOptions | undefined} options - Spawn options for process configuration\n * @param {SpawnExtra | undefined} extra - Extra options for promise-spawn\n * @returns {SpawnResult} Promise that resolves with process exit information\n *\n * @throws {SpawnError} When the process exits with non-zero code or is terminated by signal\n *\n * @example\n * // Basic usage - spawn and wait for completion\n * const result = await spawn('git', ['status'])\n * console.log(result.stdout)\n *\n * @example\n * // With options - set working directory and environment\n * const result = await spawn('npm', ['install'], {\n * cwd: '/path/to/project',\n * env: { NODE_ENV: 'production' }\n * })\n *\n * @example\n * // \u2714 DO THIS - Array-based arguments (safe)\n * spawn('git', ['commit', '-m', userMessage])\n * // Each argument is properly escaped, even if userMessage = \"foo; rm -rf /\"\n *\n * @example\n * // \u2716 NEVER DO THIS - String concatenation (vulnerable)\n * spawn(`git commit -m \"${userMessage}\"`, { shell: true })\n * // Vulnerable to injection if userMessage = '\"; rm -rf / #'\n *\n * @example\n * // Access stdin for interactive processes\n * const result = spawn('cat', [])\n * result.stdin?.write('Hello\\n')\n * result.stdin?.end()\n * const { stdout } = await result\n * console.log(stdout) // 'Hello'\n *\n * @example\n * // Handle errors with exit codes\n * try {\n * await spawn('exit', ['1'])\n * } catch (error) {\n * if (isSpawnError(error)) {\n * console.error(`Failed with code ${error.code}`)\n * console.error(error.stderr)\n * }\n * }\n */\nexport function spawn(\n cmd: string,\n args?: string[] | readonly string[],\n options?: SpawnOptions | undefined,\n extra?: SpawnExtra | undefined,\n): SpawnResult {\n // Windows cmd.exe command resolution for .cmd/.bat/.ps1 files:\n //\n // When shell: true is used on Windows with script files (.cmd, .bat, .ps1),\n // cmd.exe can have issues executing full paths. The solution is to use just\n // the command basename without extension and let cmd.exe find it via PATH.\n //\n // How cmd.exe resolves commands:\n // 1. Searches current directory first\n // 2. Then searches each directory in PATH environment variable\n // 3. For each directory, tries extensions from PATHEXT (.COM, .EXE, .BAT, .CMD, etc.)\n // 4. Executes the first match found\n //\n // Example: Given 'C:\\pnpm\\pnpm.cmd' with shell: true\n // 1. Extract basename without extension: 'pnpm'\n // 2. cmd.exe searches PATH directories for 'pnpm'\n // 3. PATHEXT causes it to try 'pnpm.com', 'pnpm.exe', 'pnpm.bat', 'pnpm.cmd', etc.\n // 4. Finds and executes 'C:\\pnpm\\pnpm.cmd'\n //\n // This approach is consistent with how other tools handle Windows execution:\n // - npm's promise-spawn: uses which.sync() to find commands in PATH\n // - cross-spawn: spawns cmd.exe with escaped arguments\n // - execa: uses cross-spawn under the hood for Windows support\n //\n // See: https://github.com/nodejs/node/issues/3675\n const shell = getOwn(options, 'shell')\n // Inline WIN32 constant for coverage mode compatibility\n const WIN32 = process.platform === 'win32'\n let actualCmd = cmd\n if (WIN32 && shell && windowsScriptExtRegExp.test(actualCmd)) {\n const path = getPath()\n // Extract just the command name without path and extension.\n actualCmd = path.basename(actualCmd, path.extname(actualCmd))\n }\n const {\n spinner: optionsSpinner = spinner,\n stripAnsi: shouldStripAnsi = true,\n ...spawnOptions\n } = { __proto__: null, ...options } as SpawnOptions\n const spinnerInstance = optionsSpinner\n const { env, stdio, stdioString = true } = spawnOptions\n // The stdio option can be a string or an array.\n // https://nodejs.org/api/child_process.html#optionsstdio\n const wasSpinning = !!spinnerInstance?.isSpinning\n const shouldStopSpinner =\n wasSpinning && !isStdioType(stdio, 'ignore') && !isStdioType(stdio, 'pipe')\n const shouldRestartSpinner = shouldStopSpinner\n if (shouldStopSpinner) {\n spinnerInstance.stop()\n }\n const npmCliPromiseSpawn = getNpmcliPromiseSpawn()\n // Use __proto__: null to prevent prototype pollution when passing to\n // third-party code, Node.js built-ins, or JavaScript built-in methods.\n // https://github.com/npm/promise-spawn\n // https://github.com/nodejs/node/blob/v24.0.1/lib/child_process.js#L674-L678\n const promiseSpawnOpts = {\n __proto__: null,\n cwd: typeof spawnOptions.cwd === 'string' ? spawnOptions.cwd : undefined,\n env: {\n __proto__: null,\n ...process.env,\n ...env,\n } as unknown as NodeJS.ProcessEnv,\n signal: abortSignal,\n stdio: spawnOptions.stdio,\n stdioString,\n shell: spawnOptions.shell,\n timeout: spawnOptions.timeout,\n uid: spawnOptions.uid,\n gid: spawnOptions.gid,\n } as unknown as PromiseSpawnOptions\n const spawnPromise = npmCliPromiseSpawn(\n actualCmd,\n args ? [...args] : [],\n promiseSpawnOpts as Parameters<typeof npmCliPromiseSpawn>[2],\n extra,\n )\n const oldSpawnPromise = spawnPromise\n let newSpawnPromise: PromiseSpawnResult\n if (shouldStripAnsi && stdioString) {\n newSpawnPromise = spawnPromise\n .then(result => {\n const strippedResult = stripAnsiFromSpawnResult(result)\n // Add exitCode as an alias for code.\n if ('code' in (strippedResult as { code?: number })) {\n ;(strippedResult as { code: number; exitCode: number }).exitCode = (\n strippedResult as { code: number }\n ).code\n }\n return strippedResult\n })\n .catch(error => {\n throw stripAnsiFromSpawnResult(error)\n }) as PromiseSpawnResult\n } else {\n newSpawnPromise = spawnPromise.then(result => {\n // Add exitCode as an alias for code.\n if ('code' in result) {\n const res = result as typeof result & { exitCode: number }\n res.exitCode = result.code\n return res\n }\n return result\n }) as PromiseSpawnResult\n }\n if (shouldRestartSpinner) {\n newSpawnPromise = newSpawnPromise.finally(() => {\n spinnerInstance.start()\n }) as PromiseSpawnResult\n }\n // Copy process and stdin properties from original promise\n ;(newSpawnPromise as unknown as PromiseSpawnResult).process =\n oldSpawnPromise.process\n ;(newSpawnPromise as unknown as PromiseSpawnResult).stdin = (\n oldSpawnPromise as unknown as PromiseSpawnResult\n ).stdin\n return newSpawnPromise as SpawnResult\n}\n\n/*@__NO_SIDE_EFFECTS__*/\n/**\n * Options for synchronously spawning a child process with {@link spawnSync}.\n * Same as {@link SpawnOptions} but excludes the `spinner` property (not applicable for synchronous execution).\n */\nexport type SpawnSyncOptions = Omit<SpawnOptions, 'spinner'>\n\n/**\n * Synchronously spawn a child process and wait for it to complete.\n * Blocks execution until the process exits, returning all output and exit information.\n *\n * WARNING: This function blocks the event loop. Use {@link spawn} for async operations.\n *\n * @param {string} cmd - Command to execute\n * @param {string[] | readonly string[] | undefined} args - Array of arguments\n * @param {SpawnSyncOptions | undefined} options - Spawn options for process configuration\n * @returns {SpawnSyncReturns<string | Buffer>} Process result with exit code and captured output\n *\n * @example\n * // Basic synchronous spawn\n * const result = spawnSync('git', ['status'])\n * console.log(result.stdout)\n * console.log(result.status) // exit code\n *\n * @example\n * // With options\n * const result = spawnSync('npm', ['install'], {\n * cwd: '/path/to/project',\n * stdioString: true\n * })\n * if (result.status !== 0) {\n * console.error(result.stderr)\n * }\n *\n * @example\n * // Get raw buffer output\n * const result = spawnSync('cat', ['binary-file'], {\n * stdioString: false\n * })\n * console.log(result.stdout) // Buffer\n *\n * @example\n * // Handle process errors\n * const result = spawnSync('nonexistent-command')\n * if (result.error) {\n * console.error('Failed to spawn:', result.error)\n * }\n */\nexport function spawnSync(\n cmd: string,\n args?: string[] | readonly string[],\n options?: SpawnSyncOptions | undefined,\n): SpawnSyncReturns<string | Buffer> {\n // Windows cmd.exe command resolution for .cmd/.bat/.ps1 files:\n // See spawn() function above for detailed explanation of this approach.\n const shell = getOwn(options, 'shell')\n // Inline WIN32 constant for coverage mode compatibility\n const WIN32 = process.platform === 'win32'\n let actualCmd = cmd\n if (WIN32 && shell && windowsScriptExtRegExp.test(actualCmd)) {\n const path = getPath()\n // Extract just the command name without path and extension.\n actualCmd = path.basename(actualCmd, path.extname(actualCmd))\n }\n const { stripAnsi: shouldStripAnsi = true, ...rawSpawnOptions } = {\n __proto__: null,\n ...options,\n } as SpawnSyncOptions\n const { stdioString: rawStdioString = true } = rawSpawnOptions\n const rawEncoding = rawStdioString ? 'utf8' : 'buffer'\n const spawnOptions = {\n encoding: rawEncoding,\n ...rawSpawnOptions,\n } as NodeSpawnOptions & { encoding: BufferEncoding | 'buffer' }\n const stdioString = spawnOptions.encoding !== 'buffer'\n const result = getChildProcess().spawnSync(actualCmd, args, spawnOptions)\n if (stdioString) {\n const { stderr, stdout } = result\n if (stdout) {\n result.stdout = stdout.toString().trim()\n }\n if (stderr) {\n result.stderr = stderr.toString().trim()\n }\n }\n return (\n shouldStripAnsi && stdioString ? stripAnsiFromSpawnResult(result) : result\n ) as SpawnSyncReturns<string | Buffer>\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BA,qBAA2C;AAE3C,oBAAwB;AAKxB,qBAA+B;AAC/B,qBAA0B;AAJ1B,MAAM,kBAAc,+BAAe;AACnC,MAAM,cAAU,2BAAW;AAQ3B,MAAM,yBAAyB;AAE/B,IAAI;AAAA;AAWJ,SAAS,kBAAkB;AACzB,MAAI,mBAAmB,QAAW;AAGhC,qBAA+B,QAAQ,oBAAoB;AAAA,EAC7D;AACA,SAAO;AACT;AAqDA,IAAI;AAAA;AAkBJ,SAAS,wBAAwB;AAC/B,MAAI,wBAAwB,QAAW;AACrC,0BAAoC,QAAQ,kCAAkC;AAAA,EAChF;AACA,SAAO;AACT;AAEA,IAAI;AAAA;AAWJ,SAAS,UAAU;AACjB,MAAI,UAAU,QAAW;AAGvB,YAAsB,QAAQ,WAAW;AAAA,EAC3C;AACA,SAAO;AACT;AAAA;AAoIO,SAAS,aAAa,OAAqC;AAChE,MAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;AAC/C,WAAO;AAAA,EACT;AAEA,QAAM,MAAM;AACZ,aACG,uBAAO,KAAK,MAAM,KAAK,OAA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