codemod 2.0.0-alpha.1 → 2.0.0-alpha.2
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 +57 -2
- package/codemod +17 -30
- package/package.json +78 -10
- package/register.d.mts +11 -0
- package/register.mjs +60 -0
- package/runtime/addon.mjs +59 -0
- package/runtime/ast-grep.mjs +93 -0
- package/runtime/context.mjs +77 -0
- package/runtime/hooks.mjs +9 -0
- package/runtime/host.d.mts +120 -0
- package/runtime/host.mjs +390 -0
- package/runtime/llm.mjs +11 -0
- package/runtime/metrics.mjs +45 -0
- package/runtime/modules.mjs +19 -0
- package/runtime/orchestrator.mjs +657 -0
- package/runtime/runtime.mjs +48 -0
- package/runtime/workflow.mjs +135 -0
- package/testing/index.d.mts +203 -0
- package/testing/index.mjs +638 -0
- package/types/index.d.ts +8 -0
- package/types/langs/angular.d.ts +5 -0
- package/types/langs/c.d.ts +5 -0
- package/types/langs/c_sharp.d.ts +5 -0
- package/types/langs/cpp.d.ts +5 -0
- package/types/langs/css.d.ts +5 -0
- package/types/langs/elixir.d.ts +5 -0
- package/types/langs/go.d.ts +5 -0
- package/types/langs/html.d.ts +5 -0
- package/types/langs/java.d.ts +5 -0
- package/types/langs/javascript.d.ts +5 -0
- package/types/langs/json.d.ts +5 -0
- package/types/langs/kotlin.d.ts +5 -0
- package/types/langs/php.d.ts +5 -0
- package/types/langs/python.d.ts +5 -0
- package/types/langs/ruby.d.ts +5 -0
- package/types/langs/rust.d.ts +5 -0
- package/types/langs/scala.d.ts +5 -0
- package/types/langs/toml.d.ts +5 -0
- package/types/langs/tsx.d.ts +5 -0
- package/types/langs/typescript.d.ts +5 -0
- package/types/langs/xml.d.ts +5 -0
- package/types/langs/yaml.d.ts +5 -0
- package/types/llm.d.ts +6 -0
- package/types/llrt/abort.d.ts +69 -0
- package/types/llrt/assert.d.ts +39 -0
- package/types/llrt/async_hooks.d.ts +210 -0
- package/types/llrt/buffer.d.ts +1186 -0
- package/types/llrt/child_process.d.ts +447 -0
- package/types/llrt/console.d.ts +210 -0
- package/types/llrt/crypto.d.ts +854 -0
- package/types/llrt/dgram.d.ts +381 -0
- package/types/llrt/dns.d.ts +124 -0
- package/types/llrt/dom-events.d.ts +51 -0
- package/types/llrt/events.d.ts +245 -0
- package/types/llrt/exceptions.d.ts +26 -0
- package/types/llrt/fetch.d.ts +332 -0
- package/types/llrt/fs/promises.d.ts +554 -0
- package/types/llrt/fs.d.ts +360 -0
- package/types/llrt/globals.d.ts +23 -0
- package/types/llrt/https.d.ts +27 -0
- package/types/llrt/index.d.ts +33 -0
- package/types/llrt/module.d.ts +285 -0
- package/types/llrt/navigator.d.ts +9 -0
- package/types/llrt/net.d.ts +488 -0
- package/types/llrt/os.d.ts +293 -0
- package/types/llrt/path.d.ts +150 -0
- package/types/llrt/perf_hooks.d.ts +23 -0
- package/types/llrt/process.d.ts +502 -0
- package/types/llrt/stream/web.d.ts +526 -0
- package/types/llrt/stream.d.ts +366 -0
- package/types/llrt/string_decoder.d.ts +63 -0
- package/types/llrt/timers.d.ts +72 -0
- package/types/llrt/timezone.d.ts +101 -0
- package/types/llrt/tty.d.ts +11 -0
- package/types/llrt/url.d.ts +774 -0
- package/types/llrt/util.d.ts +240 -0
- package/types/llrt/zlib.d.ts +177 -0
- package/types/main.d.ts +5 -0
- package/types/metrics.d.ts +5 -0
- package/types/modules/ast-grep.d.ts +634 -0
- package/types/modules/langs.d.ts +87 -0
- package/types/modules/llm.d.ts +23 -0
- package/types/modules/metrics.d.ts +107 -0
- package/types/modules/runtime.d.ts +66 -0
- package/types/modules/workflow.d.ts +750 -0
- package/types/runtime.d.ts +6 -0
- package/types/workflow.d.ts +5 -0
- package/vite.d.mts +24 -0
- package/vite.mjs +26 -0
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
declare module "child_process" {
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
import {
|
|
4
|
+
DefaultReadableStream as Readable,
|
|
5
|
+
DefaultWritableStream as Writable,
|
|
6
|
+
} from "stream";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Instances of the `ChildProcess` represent spawned child processes.
|
|
10
|
+
*
|
|
11
|
+
* Instances of `ChildProcess` are not intended to be created directly. Rather,
|
|
12
|
+
* use the {@link spawn} method to create instances of `ChildProcess`.
|
|
13
|
+
*/
|
|
14
|
+
class ChildProcess extends EventEmitter {
|
|
15
|
+
/**
|
|
16
|
+
* A `Writable Stream` that represents the child process's `stdin`.
|
|
17
|
+
*
|
|
18
|
+
* If a child process waits to read all of its input, the child will not continue
|
|
19
|
+
* until this stream has been closed via `end()`.
|
|
20
|
+
*
|
|
21
|
+
* If the child was spawned with `stdio[0]` set to anything other than `'pipe'`,
|
|
22
|
+
* then this will be `null`.
|
|
23
|
+
*
|
|
24
|
+
* `subprocess.stdin` is an alias for `subprocess.stdio[0]`. Both properties will
|
|
25
|
+
* refer to the same value.
|
|
26
|
+
*
|
|
27
|
+
* The `subprocess.stdin` property can be `null` or `undefined` if the child process could not be successfully spawned.
|
|
28
|
+
*/
|
|
29
|
+
stdin: Writable | null;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A `Readable Stream` that represents the child process's `stdout`.
|
|
33
|
+
*
|
|
34
|
+
* If the child was spawned with `stdio[1]` set to anything other than `'pipe'`,
|
|
35
|
+
* then this will be `null`.
|
|
36
|
+
*
|
|
37
|
+
* `subprocess.stdout` is an alias for `subprocess.stdio[1]`. Both properties will
|
|
38
|
+
* refer to the same value.
|
|
39
|
+
*
|
|
40
|
+
* ```js
|
|
41
|
+
* const { spawn } = require('child_process');
|
|
42
|
+
*
|
|
43
|
+
* const subprocess = spawn('ls');
|
|
44
|
+
*
|
|
45
|
+
* subprocess.stdout.on('data', (data) => {
|
|
46
|
+
* console.log(`Received chunk ${data}`);
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* The `subprocess.stdout` property can be `null` or `undefined` if the child process could not be successfully spawned.
|
|
51
|
+
*/
|
|
52
|
+
stdout: Readable | null;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A `Readable Stream` that represents the child process's `stderr`.
|
|
56
|
+
*
|
|
57
|
+
* If the child was spawned with `stdio[2]` set to anything other than `'pipe'`,
|
|
58
|
+
* then this will be `null`.
|
|
59
|
+
*
|
|
60
|
+
* `subprocess.stderr` is an alias for `subprocess.stdio[2]`. Both properties will
|
|
61
|
+
* refer to the same value.
|
|
62
|
+
*
|
|
63
|
+
* The `subprocess.stderr` property can be `null` or `undefined` if the child process could not be successfully spawned.
|
|
64
|
+
*/
|
|
65
|
+
stderr: Readable | null;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Returns the process identifier (PID) of the child process. If the child process
|
|
69
|
+
* fails to spawn due to errors, then the value is `undefined` and `error` is
|
|
70
|
+
* emitted.
|
|
71
|
+
*
|
|
72
|
+
* ```js
|
|
73
|
+
* const { spawn } = require('child_process');
|
|
74
|
+
* const grep = spawn('grep', ['ssh']);
|
|
75
|
+
*
|
|
76
|
+
* console.log(`Spawned child pid: ${grep.pid}`);
|
|
77
|
+
* grep.stdin.end();
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
readonly pid?: number | undefined;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The `subprocess.kill()` method sends a signal to the child process. If no
|
|
84
|
+
* argument is given, the process will be sent the `'SIGTERM'` signal. See [`signal(7)`](http://man7.org/linux/man-pages/man7/signal.7.html) for a list of available signals. This function
|
|
85
|
+
* returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise.
|
|
86
|
+
*
|
|
87
|
+
* ```js
|
|
88
|
+
* const { spawn } = require('child_process');
|
|
89
|
+
* const grep = spawn('grep', ['ssh']);
|
|
90
|
+
*
|
|
91
|
+
* grep.on('close', (code, signal) => {
|
|
92
|
+
* console.log(
|
|
93
|
+
* `child process terminated due to receipt of signal ${signal}`);
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* // Send SIGHUP to process.
|
|
97
|
+
* grep.kill('SIGHUP');
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* The `ChildProcess` object may emit an `'error'` event if the signal
|
|
101
|
+
* cannot be delivered. Sending a signal to a child process that has already exited
|
|
102
|
+
* is not an error but may have unforeseen consequences. Specifically, if the
|
|
103
|
+
* process identifier (PID) has been reassigned to another process, the signal will
|
|
104
|
+
* be delivered to that process instead which can have unexpected results.
|
|
105
|
+
*
|
|
106
|
+
* While the function is called `kill`, the signal delivered to the child process
|
|
107
|
+
* may not actually terminate the process.
|
|
108
|
+
*
|
|
109
|
+
* See [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) for reference.
|
|
110
|
+
*
|
|
111
|
+
* On Windows, where POSIX signals do not exist, the `signal` argument will be
|
|
112
|
+
* ignored, and the process will be killed forcefully and abruptly (similar to `'SIGKILL'`).
|
|
113
|
+
* See `Signal Events` for more details.
|
|
114
|
+
*
|
|
115
|
+
* On Linux, child processes of child processes will not be terminated
|
|
116
|
+
* when attempting to kill their parent. This is likely to happen when running a
|
|
117
|
+
* new process in a shell or with the use of the `shell` option of `ChildProcess`:
|
|
118
|
+
*
|
|
119
|
+
* ```js
|
|
120
|
+
* 'use strict';
|
|
121
|
+
* const { spawn } = require('child_process');
|
|
122
|
+
*
|
|
123
|
+
* const subprocess = spawn(
|
|
124
|
+
* 'sh',
|
|
125
|
+
* [
|
|
126
|
+
* '-c',
|
|
127
|
+
* `node -e "setInterval(() => {
|
|
128
|
+
* console.log(process.pid, 'is alive')
|
|
129
|
+
* }, 500);"`,
|
|
130
|
+
* ], {
|
|
131
|
+
* stdio: ['inherit', 'inherit', 'inherit'],
|
|
132
|
+
* },
|
|
133
|
+
* );
|
|
134
|
+
*
|
|
135
|
+
* setTimeout(() => {
|
|
136
|
+
* subprocess.kill(); // Does not terminate the Node.js process in the shell.
|
|
137
|
+
* }, 2000);
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
kill(signal?: QuickJS.Signals | number): boolean;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Calls {@link ChildProcess.kill} with `'SIGTERM'`.
|
|
144
|
+
*/
|
|
145
|
+
[Symbol.dispose](): void;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* events.EventEmitter
|
|
149
|
+
* 1. close
|
|
150
|
+
* 2. error
|
|
151
|
+
* 3. exit
|
|
152
|
+
*/
|
|
153
|
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
154
|
+
addListener(
|
|
155
|
+
event: "close",
|
|
156
|
+
listener: (code: number | null, signal: QuickJS.Signals | null) => void
|
|
157
|
+
): this;
|
|
158
|
+
addListener(event: "error", listener: (err: Error) => void): this;
|
|
159
|
+
addListener(
|
|
160
|
+
event: "exit",
|
|
161
|
+
listener: (code: number | null, signal: QuickJS.Signals | null) => void
|
|
162
|
+
): this;
|
|
163
|
+
emit(event: string | symbol, ...args: any[]): boolean;
|
|
164
|
+
emit(
|
|
165
|
+
event: "close",
|
|
166
|
+
code: number | null,
|
|
167
|
+
signal: QuickJS.Signals | null
|
|
168
|
+
): boolean;
|
|
169
|
+
emit(event: "error", err: Error): boolean;
|
|
170
|
+
emit(
|
|
171
|
+
event: "exit",
|
|
172
|
+
code: number | null,
|
|
173
|
+
signal: QuickJS.Signals | null
|
|
174
|
+
): boolean;
|
|
175
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
|
176
|
+
on(
|
|
177
|
+
event: "close",
|
|
178
|
+
listener: (code: number | null, signal: QuickJS.Signals | null) => void
|
|
179
|
+
): this;
|
|
180
|
+
on(event: "error", listener: (err: Error) => void): this;
|
|
181
|
+
on(
|
|
182
|
+
event: "exit",
|
|
183
|
+
listener: (code: number | null, signal: QuickJS.Signals | null) => void
|
|
184
|
+
): this;
|
|
185
|
+
once(event: string, listener: (...args: any[]) => void): this;
|
|
186
|
+
once(
|
|
187
|
+
event: "close",
|
|
188
|
+
listener: (code: number | null, signal: QuickJS.Signals | null) => void
|
|
189
|
+
): this;
|
|
190
|
+
once(event: "error", listener: (err: Error) => void): this;
|
|
191
|
+
once(
|
|
192
|
+
event: "exit",
|
|
193
|
+
listener: (code: number | null, signal: QuickJS.Signals | null) => void
|
|
194
|
+
): this;
|
|
195
|
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
|
196
|
+
prependListener(
|
|
197
|
+
event: "close",
|
|
198
|
+
listener: (code: number | null, signal: QuickJS.Signals | null) => void
|
|
199
|
+
): this;
|
|
200
|
+
prependListener(event: "error", listener: (err: Error) => void): this;
|
|
201
|
+
prependListener(
|
|
202
|
+
event: "exit",
|
|
203
|
+
listener: (code: number | null, signal: QuickJS.Signals | null) => void
|
|
204
|
+
): this;
|
|
205
|
+
prependOnceListener(
|
|
206
|
+
event: string,
|
|
207
|
+
listener: (...args: any[]) => void
|
|
208
|
+
): this;
|
|
209
|
+
prependOnceListener(
|
|
210
|
+
event: "close",
|
|
211
|
+
listener: (code: number | null, signal: QuickJS.Signals | null) => void
|
|
212
|
+
): this;
|
|
213
|
+
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
|
214
|
+
prependOnceListener(
|
|
215
|
+
event: "exit",
|
|
216
|
+
listener: (code: number | null, signal: QuickJS.Signals | null) => void
|
|
217
|
+
): this;
|
|
218
|
+
}
|
|
219
|
+
// return this object when stdio option is undefined or not specified
|
|
220
|
+
interface ChildProcessWithoutNullStreams extends ChildProcess {
|
|
221
|
+
stdin: Writable;
|
|
222
|
+
stdout: Readable;
|
|
223
|
+
stderr: Readable;
|
|
224
|
+
}
|
|
225
|
+
// return this object when stdio option is a tuple of 3
|
|
226
|
+
interface ChildProcessByStdio<
|
|
227
|
+
I extends null | Writable,
|
|
228
|
+
O extends null | Readable,
|
|
229
|
+
E extends null | Readable,
|
|
230
|
+
> extends ChildProcess {
|
|
231
|
+
stdin: I;
|
|
232
|
+
stdout: O;
|
|
233
|
+
stderr: E;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
type IOType = "pipe" | "ignore" | "inherit";
|
|
237
|
+
type StdioOptions = IOType | Array<IOType | number | null | undefined>;
|
|
238
|
+
|
|
239
|
+
interface ProcessEnvOptions {
|
|
240
|
+
uid?: number | undefined;
|
|
241
|
+
gid?: number | undefined;
|
|
242
|
+
cwd?: string | undefined;
|
|
243
|
+
}
|
|
244
|
+
interface SpawnOptions extends ProcessEnvOptions {
|
|
245
|
+
/**
|
|
246
|
+
* Can be set to 'pipe', 'inherit', or 'ignore', or an array of these strings.
|
|
247
|
+
* If passed as an array, the first element is used for `stdin`, the second for
|
|
248
|
+
* `stdout`, and the third for `stderr`.
|
|
249
|
+
*
|
|
250
|
+
* @default 'pipe'
|
|
251
|
+
*/
|
|
252
|
+
stdio?: StdioOptions | undefined;
|
|
253
|
+
shell?: boolean | string | undefined;
|
|
254
|
+
windowsVerbatimArguments?: boolean | undefined;
|
|
255
|
+
}
|
|
256
|
+
interface SpawnOptionsWithoutStdio extends SpawnOptions {
|
|
257
|
+
stdio?: StdioPipeNamed | StdioPipe[] | undefined;
|
|
258
|
+
}
|
|
259
|
+
type StdioNull = "inherit" | "ignore";
|
|
260
|
+
type StdioPipeNamed = "pipe";
|
|
261
|
+
type StdioPipe = undefined | null | StdioPipeNamed;
|
|
262
|
+
interface SpawnOptionsWithStdioTuple<
|
|
263
|
+
Stdin extends StdioNull | StdioPipe,
|
|
264
|
+
Stdout extends StdioNull | StdioPipe,
|
|
265
|
+
Stderr extends StdioNull | StdioPipe,
|
|
266
|
+
> extends SpawnOptions {
|
|
267
|
+
stdio: [Stdin, Stdout, Stderr];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* The `child_process.spawn()` method spawns a new process using the given `command`, with command-line arguments in `args`.
|
|
272
|
+
* If omitted, `args` defaults to an empty array.
|
|
273
|
+
*
|
|
274
|
+
* **If the `shell` option is enabled, do not pass unsanitized user input to this**
|
|
275
|
+
* **function. Any input containing shell metacharacters may be used to trigger**
|
|
276
|
+
* **arbitrary command execution.**
|
|
277
|
+
*
|
|
278
|
+
* A third argument may be used to specify additional options.
|
|
279
|
+
*
|
|
280
|
+
* Use `cwd` to specify the working directory from which the process is spawned.
|
|
281
|
+
* If not given, the default is to inherit the current working directory. If given,
|
|
282
|
+
* but the path does not exist, the child process emits an `ENOENT` error
|
|
283
|
+
* and exits immediately. `ENOENT` is also emitted when the command
|
|
284
|
+
* does not exist.
|
|
285
|
+
*
|
|
286
|
+
* Example of running `ls -lh /usr`, capturing `stdout`, `stderr`, and the
|
|
287
|
+
* exit code:
|
|
288
|
+
*
|
|
289
|
+
* ```js
|
|
290
|
+
* const { spawn } = require('child_process');
|
|
291
|
+
* const ls = spawn('ls', ['-lh', '/usr']);
|
|
292
|
+
*
|
|
293
|
+
* ls.stdout.on('data', (data) => {
|
|
294
|
+
* console.log(`stdout: ${data}`);
|
|
295
|
+
* });
|
|
296
|
+
*
|
|
297
|
+
* ls.stderr.on('data', (data) => {
|
|
298
|
+
* console.error(`stderr: ${data}`);
|
|
299
|
+
* });
|
|
300
|
+
*
|
|
301
|
+
* ls.on('close', (code) => {
|
|
302
|
+
* console.log(`child process exited with code ${code}`);
|
|
303
|
+
* });
|
|
304
|
+
* ```
|
|
305
|
+
*
|
|
306
|
+
* Example: A very elaborate way to run `ps ax | grep ssh`
|
|
307
|
+
*
|
|
308
|
+
* ```js
|
|
309
|
+
* const { spawn } = require('child_process');
|
|
310
|
+
* const ps = spawn('ps', ['ax']);
|
|
311
|
+
* const grep = spawn('grep', ['ssh']);
|
|
312
|
+
*
|
|
313
|
+
* ps.stdout.on('data', (data) => {
|
|
314
|
+
* grep.stdin.write(data);
|
|
315
|
+
* });
|
|
316
|
+
*
|
|
317
|
+
* ps.stderr.on('data', (data) => {
|
|
318
|
+
* console.error(`ps stderr: ${data}`);
|
|
319
|
+
* });
|
|
320
|
+
*
|
|
321
|
+
* ps.on('close', (code) => {
|
|
322
|
+
* if (code !== 0) {
|
|
323
|
+
* console.log(`ps process exited with code ${code}`);
|
|
324
|
+
* }
|
|
325
|
+
* grep.stdin.end();
|
|
326
|
+
* });
|
|
327
|
+
*
|
|
328
|
+
* grep.stdout.on('data', (data) => {
|
|
329
|
+
* console.log(data.toString());
|
|
330
|
+
* });
|
|
331
|
+
*
|
|
332
|
+
* grep.stderr.on('data', (data) => {
|
|
333
|
+
* console.error(`grep stderr: ${data}`);
|
|
334
|
+
* });
|
|
335
|
+
*
|
|
336
|
+
* grep.on('close', (code) => {
|
|
337
|
+
* if (code !== 0) {
|
|
338
|
+
* console.log(`grep process exited with code ${code}`);
|
|
339
|
+
* }
|
|
340
|
+
* });
|
|
341
|
+
* ```
|
|
342
|
+
*
|
|
343
|
+
* Example of checking for failed `spawn`:
|
|
344
|
+
*
|
|
345
|
+
* ```js
|
|
346
|
+
* const { spawn } = require('child_process');
|
|
347
|
+
* const subprocess = spawn('bad_command');
|
|
348
|
+
*
|
|
349
|
+
* subprocess.on('error', (err) => {
|
|
350
|
+
* console.error('Failed to start subprocess.');
|
|
351
|
+
* });
|
|
352
|
+
* ```
|
|
353
|
+
*
|
|
354
|
+
* Certain platforms (macOS, Linux) will use the value of `argv[0]` for the process
|
|
355
|
+
* title while others (Windows, SunOS) will use `command`.
|
|
356
|
+
* @param command The command to run.
|
|
357
|
+
* @param args List of string arguments.
|
|
358
|
+
*/
|
|
359
|
+
function spawn(
|
|
360
|
+
command: string,
|
|
361
|
+
options?: SpawnOptionsWithoutStdio
|
|
362
|
+
): ChildProcessWithoutNullStreams;
|
|
363
|
+
function spawn(
|
|
364
|
+
command: string,
|
|
365
|
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>
|
|
366
|
+
): ChildProcessByStdio<Writable, Readable, Readable>;
|
|
367
|
+
function spawn(
|
|
368
|
+
command: string,
|
|
369
|
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>
|
|
370
|
+
): ChildProcessByStdio<Writable, Readable, null>;
|
|
371
|
+
function spawn(
|
|
372
|
+
command: string,
|
|
373
|
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>
|
|
374
|
+
): ChildProcessByStdio<Writable, null, Readable>;
|
|
375
|
+
function spawn(
|
|
376
|
+
command: string,
|
|
377
|
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>
|
|
378
|
+
): ChildProcessByStdio<null, Readable, Readable>;
|
|
379
|
+
function spawn(
|
|
380
|
+
command: string,
|
|
381
|
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>
|
|
382
|
+
): ChildProcessByStdio<Writable, null, null>;
|
|
383
|
+
function spawn(
|
|
384
|
+
command: string,
|
|
385
|
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>
|
|
386
|
+
): ChildProcessByStdio<null, Readable, null>;
|
|
387
|
+
function spawn(
|
|
388
|
+
command: string,
|
|
389
|
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>
|
|
390
|
+
): ChildProcessByStdio<null, null, Readable>;
|
|
391
|
+
function spawn(
|
|
392
|
+
command: string,
|
|
393
|
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>
|
|
394
|
+
): ChildProcessByStdio<null, null, null>;
|
|
395
|
+
function spawn(command: string, options: SpawnOptions): ChildProcess;
|
|
396
|
+
// overloads of spawn with 'args'
|
|
397
|
+
function spawn(
|
|
398
|
+
command: string,
|
|
399
|
+
args?: readonly string[],
|
|
400
|
+
options?: SpawnOptionsWithoutStdio
|
|
401
|
+
): ChildProcessWithoutNullStreams;
|
|
402
|
+
function spawn(
|
|
403
|
+
command: string,
|
|
404
|
+
args: readonly string[],
|
|
405
|
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>
|
|
406
|
+
): ChildProcessByStdio<Writable, Readable, Readable>;
|
|
407
|
+
function spawn(
|
|
408
|
+
command: string,
|
|
409
|
+
args: readonly string[],
|
|
410
|
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>
|
|
411
|
+
): ChildProcessByStdio<Writable, Readable, null>;
|
|
412
|
+
function spawn(
|
|
413
|
+
command: string,
|
|
414
|
+
args: readonly string[],
|
|
415
|
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>
|
|
416
|
+
): ChildProcessByStdio<Writable, null, Readable>;
|
|
417
|
+
function spawn(
|
|
418
|
+
command: string,
|
|
419
|
+
args: readonly string[],
|
|
420
|
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>
|
|
421
|
+
): ChildProcessByStdio<null, Readable, Readable>;
|
|
422
|
+
function spawn(
|
|
423
|
+
command: string,
|
|
424
|
+
args: readonly string[],
|
|
425
|
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>
|
|
426
|
+
): ChildProcessByStdio<Writable, null, null>;
|
|
427
|
+
function spawn(
|
|
428
|
+
command: string,
|
|
429
|
+
args: readonly string[],
|
|
430
|
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>
|
|
431
|
+
): ChildProcessByStdio<null, Readable, null>;
|
|
432
|
+
function spawn(
|
|
433
|
+
command: string,
|
|
434
|
+
args: readonly string[],
|
|
435
|
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>
|
|
436
|
+
): ChildProcessByStdio<null, null, Readable>;
|
|
437
|
+
function spawn(
|
|
438
|
+
command: string,
|
|
439
|
+
args: readonly string[],
|
|
440
|
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>
|
|
441
|
+
): ChildProcessByStdio<null, null, null>;
|
|
442
|
+
function spawn(
|
|
443
|
+
command: string,
|
|
444
|
+
args: readonly string[],
|
|
445
|
+
options: SpawnOptions
|
|
446
|
+
): ChildProcess;
|
|
447
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `console` module provides a simple debugging console that is similar to
|
|
3
|
+
* the JavaScript console mechanism provided by web browsers.
|
|
4
|
+
*
|
|
5
|
+
* Example using the global `console`:
|
|
6
|
+
*
|
|
7
|
+
* ```js
|
|
8
|
+
* console.log('hello world');
|
|
9
|
+
* // Prints: hello world, to stdout
|
|
10
|
+
* console.log('hello %s', 'world');
|
|
11
|
+
* // Prints: hello world, to stdout
|
|
12
|
+
* console.error(new Error('Whoops, something bad happened'));
|
|
13
|
+
* // Prints error message and stack trace to stderr:
|
|
14
|
+
* // Error: Whoops, something bad happened
|
|
15
|
+
* // at [eval]:5:15
|
|
16
|
+
* // at Script.runInThisContext (vm:132:18)
|
|
17
|
+
* // at Object.runInThisContext (vm:309:38)
|
|
18
|
+
* // at internal/process/execution:77:19
|
|
19
|
+
* // at [eval]-wrapper:6:22
|
|
20
|
+
* // at evalScript (internal/process/execution:76:60)
|
|
21
|
+
* // at internal/main/eval_string:23:3
|
|
22
|
+
*
|
|
23
|
+
* const name = 'Will Robinson';
|
|
24
|
+
* console.warn(`Danger ${name}! Danger!`);
|
|
25
|
+
* // Prints: Danger Will Robinson! Danger!, to stderr
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* Example using the `Console` class:
|
|
29
|
+
*
|
|
30
|
+
* ```js
|
|
31
|
+
* const out = getStreamSomehow();
|
|
32
|
+
* const err = getStreamSomehow();
|
|
33
|
+
* const myConsole = new console.Console(out, err);
|
|
34
|
+
*
|
|
35
|
+
* myConsole.log('hello world');
|
|
36
|
+
* // Prints: hello world, to out
|
|
37
|
+
* myConsole.log('hello %s', 'world');
|
|
38
|
+
* // Prints: hello world, to out
|
|
39
|
+
* myConsole.error(new Error('Whoops, something bad happened'));
|
|
40
|
+
* // Prints: [Error: Whoops, something bad happened], to err
|
|
41
|
+
*
|
|
42
|
+
* const name = 'Will Robinson';
|
|
43
|
+
* myConsole.warn(`Danger ${name}! Danger!`);
|
|
44
|
+
* // Prints: Danger Will Robinson! Danger!, to err
|
|
45
|
+
* ```
|
|
46
|
+
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/console.js)
|
|
47
|
+
*/
|
|
48
|
+
declare module "console" {
|
|
49
|
+
global {
|
|
50
|
+
// This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build
|
|
51
|
+
interface Console {
|
|
52
|
+
/**
|
|
53
|
+
* `console.assert()` writes a message if `value` is [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) or omitted. It only
|
|
54
|
+
* writes a message and does not otherwise affect execution. The output always
|
|
55
|
+
* starts with `"Assertion failed"`. If provided, `message` is formatted using
|
|
56
|
+
* [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args).
|
|
57
|
+
*
|
|
58
|
+
* If `value` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), nothing happens.
|
|
59
|
+
*
|
|
60
|
+
* ```js
|
|
61
|
+
* console.assert(true, 'does nothing');
|
|
62
|
+
*
|
|
63
|
+
* console.assert(false, 'Whoops %s work', 'didn\'t');
|
|
64
|
+
* // Assertion failed: Whoops didn't work
|
|
65
|
+
*
|
|
66
|
+
* console.assert();
|
|
67
|
+
* // Assertion failed
|
|
68
|
+
* ```
|
|
69
|
+
* @param value The value tested for being truthy.
|
|
70
|
+
* @param message All arguments besides `value` are used as error message.
|
|
71
|
+
*/
|
|
72
|
+
assert(value: any, message?: string, ...optionalParams: any[]): void;
|
|
73
|
+
/**
|
|
74
|
+
* When `stdout` is a TTY, calling `console.clear()` will attempt to clear the
|
|
75
|
+
* TTY. When `stdout` is not a TTY, this method does nothing.
|
|
76
|
+
*
|
|
77
|
+
* The specific operation of `console.clear()` can vary across operating systems
|
|
78
|
+
* and terminal types. For most Linux operating systems, `console.clear()` operates similarly to the `clear` shell command. On Windows, `console.clear()` will clear only the output in the
|
|
79
|
+
* current terminal viewport for the LLRT
|
|
80
|
+
* binary.
|
|
81
|
+
*/
|
|
82
|
+
clear(): void;
|
|
83
|
+
/**
|
|
84
|
+
* The `console.debug()` function is an alias for {@link log}.
|
|
85
|
+
*/
|
|
86
|
+
debug(message?: any, ...optionalParams: any[]): void;
|
|
87
|
+
/**
|
|
88
|
+
* Prints to `stderr` with newline. Multiple arguments can be passed, with the
|
|
89
|
+
* first used as the primary message and all additional used as substitution
|
|
90
|
+
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html)
|
|
91
|
+
* (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)).
|
|
92
|
+
*
|
|
93
|
+
* ```js
|
|
94
|
+
* const code = 5;
|
|
95
|
+
* console.error('error #%d', code);
|
|
96
|
+
* // Prints: error #5, to stderr
|
|
97
|
+
* console.error('error', code);
|
|
98
|
+
* // Prints: error 5, to stderr
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* If formatting elements (e.g. `%d`) are not found in the first string then
|
|
102
|
+
* [`util.inspect()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilinspectobject-options) is called on each argument and the
|
|
103
|
+
* resulting string values are concatenated. See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)
|
|
104
|
+
* for more information.
|
|
105
|
+
*/
|
|
106
|
+
error(message?: any, ...optionalParams: any[]): void;
|
|
107
|
+
/**
|
|
108
|
+
* The `console.info()` function is an alias for {@link log}.
|
|
109
|
+
*/
|
|
110
|
+
info(message?: any, ...optionalParams: any[]): void;
|
|
111
|
+
/**
|
|
112
|
+
* Prints to `stdout` with newline. Multiple arguments can be passed, with the
|
|
113
|
+
* first used as the primary message and all additional used as substitution
|
|
114
|
+
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html)
|
|
115
|
+
* (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)).
|
|
116
|
+
*
|
|
117
|
+
* ```js
|
|
118
|
+
* const count = 5;
|
|
119
|
+
* console.log('count: %d', count);
|
|
120
|
+
* // Prints: count: 5, to stdout
|
|
121
|
+
* console.log('count:', count);
|
|
122
|
+
* // Prints: count: 5, to stdout
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.
|
|
126
|
+
*/
|
|
127
|
+
log(message?: any, ...optionalParams: any[]): void;
|
|
128
|
+
/**
|
|
129
|
+
* Prints to `stderr` the string `'Trace: '`, followed by the [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)
|
|
130
|
+
* formatted message and stack trace to the current position in the code.
|
|
131
|
+
*
|
|
132
|
+
* ```js
|
|
133
|
+
* console.trace('Show me');
|
|
134
|
+
* // Prints: (stack trace will vary based on where trace is called)
|
|
135
|
+
* // Trace: Show me
|
|
136
|
+
* // at repl:2:9
|
|
137
|
+
* // at REPLServer.defaultEval (repl.js:248:27)
|
|
138
|
+
* // at bound (domain.js:287:14)
|
|
139
|
+
* // at REPLServer.runBound [as eval] (domain.js:300:12)
|
|
140
|
+
* // at REPLServer.<anonymous> (repl.js:412:12)
|
|
141
|
+
* // at emitOne (events.js:82:20)
|
|
142
|
+
* // at REPLServer.emit (events.js:169:7)
|
|
143
|
+
* // at REPLServer.Interface._onLine (readline.js:210:10)
|
|
144
|
+
* // at REPLServer.Interface._line (readline.js:549:8)
|
|
145
|
+
* // at REPLServer.Interface._ttyWrite (readline.js:826:14)
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
trace(message?: any, ...optionalParams: any[]): void;
|
|
149
|
+
/**
|
|
150
|
+
* The `console.warn()` function is an alias for {@link error}.
|
|
151
|
+
*/
|
|
152
|
+
warn(message?: any, ...optionalParams: any[]): void;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The `console` module provides a simple debugging console that is similar to the
|
|
156
|
+
* JavaScript console mechanism provided by web browsers.
|
|
157
|
+
*
|
|
158
|
+
*
|
|
159
|
+
* _**Warning**_: The global console object's methods are neither consistently
|
|
160
|
+
* synchronous like the browser APIs they resemble, nor are they consistently
|
|
161
|
+
* asynchronous like all other LLRT streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for
|
|
162
|
+
* more information.
|
|
163
|
+
*
|
|
164
|
+
* Example using the global `console`:
|
|
165
|
+
*
|
|
166
|
+
* ```js
|
|
167
|
+
* console.log('hello world');
|
|
168
|
+
* // Prints: hello world, to stdout
|
|
169
|
+
* console.log('hello %s', 'world');
|
|
170
|
+
* // Prints: hello world, to stdout
|
|
171
|
+
* console.error(new Error('Whoops, something bad happened'));
|
|
172
|
+
* // Prints error message and stack trace to stderr:
|
|
173
|
+
* // Error: Whoops, something bad happened
|
|
174
|
+
* // at [eval]:5:15
|
|
175
|
+
* // at Script.runInThisContext (vm:132:18)
|
|
176
|
+
* // at Object.runInThisContext (vm:309:38)
|
|
177
|
+
* // at internal/process/execution:77:19
|
|
178
|
+
* // at [eval]-wrapper:6:22
|
|
179
|
+
* // at evalScript (internal/process/execution:76:60)
|
|
180
|
+
* // at internal/main/eval_string:23:3
|
|
181
|
+
*
|
|
182
|
+
* const name = 'Will Robinson';
|
|
183
|
+
* console.warn(`Danger ${name}! Danger!`);
|
|
184
|
+
* // Prints: Danger Will Robinson! Danger!, to stderr
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
187
|
+
* Example using the `Console` class:
|
|
188
|
+
*
|
|
189
|
+
* ```js
|
|
190
|
+
* const out = getStreamSomehow();
|
|
191
|
+
* const err = getStreamSomehow();
|
|
192
|
+
* const myConsole = new console.Console(out, err);
|
|
193
|
+
*
|
|
194
|
+
* myConsole.log('hello world');
|
|
195
|
+
* // Prints: hello world, to out
|
|
196
|
+
* myConsole.log('hello %s', 'world');
|
|
197
|
+
* // Prints: hello world, to out
|
|
198
|
+
* myConsole.error(new Error('Whoops, something bad happened'));
|
|
199
|
+
* // Prints: [Error: Whoops, something bad happened], to err
|
|
200
|
+
*
|
|
201
|
+
* const name = 'Will Robinson';
|
|
202
|
+
* myConsole.warn(`Danger ${name}! Danger!`);
|
|
203
|
+
* // Prints: Danger Will Robinson! Danger!, to err
|
|
204
|
+
* ```
|
|
205
|
+
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/console.js)
|
|
206
|
+
*/
|
|
207
|
+
var console: Console;
|
|
208
|
+
}
|
|
209
|
+
export = globalThis.console;
|
|
210
|
+
}
|