@optique/run 1.0.12-dev.2690 → 1.0.12-dev.2703
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/run.d.cts +40 -0
- package/dist/run.d.ts +40 -0
- package/package.json +2 -2
package/dist/run.d.cts
CHANGED
|
@@ -33,6 +33,9 @@ interface RunOptions {
|
|
|
33
33
|
* after the whole text has been written, even if the reader is slow, so that
|
|
34
34
|
* exiting the process right afterward does not truncate the output.
|
|
35
35
|
*
|
|
36
|
+
* A custom writer using `console.log()` can lose large piped output on
|
|
37
|
+
* affected Bun versions. See the Bun output warning on {@link run}.
|
|
38
|
+
*
|
|
36
39
|
* @default Writes to `process.stdout` with a trailing newline
|
|
37
40
|
*/
|
|
38
41
|
readonly stdout?: (text: string) => void;
|
|
@@ -45,12 +48,27 @@ interface RunOptions {
|
|
|
45
48
|
* after the whole text has been written, even if the reader is slow, so that
|
|
46
49
|
* exiting the process right afterward does not truncate the output.
|
|
47
50
|
*
|
|
51
|
+
* A custom writer using `console.error()` can lose large piped output on
|
|
52
|
+
* affected Bun versions. See the Bun output warning on {@link run}.
|
|
53
|
+
*
|
|
48
54
|
* @default Writes to `process.stderr` with a trailing newline
|
|
49
55
|
*/
|
|
50
56
|
readonly stderr?: (text: string) => void;
|
|
51
57
|
/**
|
|
52
58
|
* Function used to exit the process on help/version display or parse error.
|
|
53
59
|
*
|
|
60
|
+
* This hook is synchronous and runs immediately after an output handler
|
|
61
|
+
* returns. With the default `process.exit()` handler, custom `stdout` and
|
|
62
|
+
* `stderr` handlers must finish writing synchronously before returning.
|
|
63
|
+
* The default exit handler also does not wait for writes queued by
|
|
64
|
+
* application code.
|
|
65
|
+
*
|
|
66
|
+
* To wait for asynchronous writes, record their completion promises and
|
|
67
|
+
* throw an exception carrying the exit code from `onExit`. Catch that
|
|
68
|
+
* exception outside the runner, await the recorded promises, then call
|
|
69
|
+
* `process.exit()` with that code.
|
|
70
|
+
* An arbitrary delay does not guarantee that output has been flushed.
|
|
71
|
+
*
|
|
54
72
|
* @default `process.exit`
|
|
55
73
|
*/
|
|
56
74
|
readonly onExit?: (exitCode: number) => never;
|
|
@@ -295,6 +313,24 @@ type AcceptExactOptionalRunOptions<TOptions> = [TOptions] extends [RunOptions |
|
|
|
295
313
|
* - Exit the process with appropriate codes on help or error
|
|
296
314
|
* - Format output according to terminal capabilities
|
|
297
315
|
*
|
|
316
|
+
* On affected Bun versions, importing `@optique/run` can cause large
|
|
317
|
+
* application `console.log()` output to be silently truncated when piped,
|
|
318
|
+
* even after successful parsing and natural process exit. This is
|
|
319
|
+
* [Bun issue #36419](https://github.com/oven-sh/bun/issues/36419), reported
|
|
320
|
+
* on macOS arm64 with Bun 1.3.14 and 1.4.2. Use `process.stdout.write()`
|
|
321
|
+
* instead of `console.log()` for application data, and `process.stderr.write()`
|
|
322
|
+
* instead of `console.error()` for diagnostics. Both console methods can lose
|
|
323
|
+
* large piped output. Let the process exit naturally. If explicit termination
|
|
324
|
+
* is necessary, wait for the completion callbacks of all pending stdout/stderr
|
|
325
|
+
* writes before calling `process.exit()`; a delay is not a flush guarantee. Waiting after `console.log()` or `console.error()` cannot
|
|
326
|
+
* recover dropped bytes.
|
|
327
|
+
*
|
|
328
|
+
* Setting `colors` and `maxWidth` explicitly does not avoid this Bun bug:
|
|
329
|
+
* importing `node:process`, which this module does, was enough to trigger it
|
|
330
|
+
* in Bun 1.3.14. The upstream fix was merged in
|
|
331
|
+
* [Bun PR #43868](https://github.com/oven-sh/bun/pull/43868); check whether
|
|
332
|
+
* your Bun release includes it.
|
|
333
|
+
*
|
|
298
334
|
* @template T The parser type being executed.
|
|
299
335
|
* @param parser The command-line parser to execute.
|
|
300
336
|
* @param options Configuration options for customizing behavior.
|
|
@@ -378,6 +414,8 @@ declare function run<T extends Parser<Mode, unknown, unknown>>(parser: T, option
|
|
|
378
414
|
* Use this when you know your parser is sync-only to get direct return values
|
|
379
415
|
* without Promise wrappers.
|
|
380
416
|
*
|
|
417
|
+
* See {@link run} for Bun's piped console output warning and workarounds.
|
|
418
|
+
*
|
|
381
419
|
* @template T The sync parser type being executed.
|
|
382
420
|
* @param parser The synchronous command-line parser to execute.
|
|
383
421
|
* @param options Configuration options for customizing behavior.
|
|
@@ -406,6 +444,8 @@ declare function runSync<T extends Parser<"sync", unknown, unknown>>(parser: T,
|
|
|
406
444
|
* Promise. Use this when working with parsers that may contain async
|
|
407
445
|
* value parsers.
|
|
408
446
|
*
|
|
447
|
+
* See {@link run} for Bun's piped console output warning and workarounds.
|
|
448
|
+
*
|
|
409
449
|
* @template T The parser type being executed.
|
|
410
450
|
* @param parser The command-line parser to execute.
|
|
411
451
|
* @param options Configuration options for customizing behavior.
|
package/dist/run.d.ts
CHANGED
|
@@ -33,6 +33,9 @@ interface RunOptions {
|
|
|
33
33
|
* after the whole text has been written, even if the reader is slow, so that
|
|
34
34
|
* exiting the process right afterward does not truncate the output.
|
|
35
35
|
*
|
|
36
|
+
* A custom writer using `console.log()` can lose large piped output on
|
|
37
|
+
* affected Bun versions. See the Bun output warning on {@link run}.
|
|
38
|
+
*
|
|
36
39
|
* @default Writes to `process.stdout` with a trailing newline
|
|
37
40
|
*/
|
|
38
41
|
readonly stdout?: (text: string) => void;
|
|
@@ -45,12 +48,27 @@ interface RunOptions {
|
|
|
45
48
|
* after the whole text has been written, even if the reader is slow, so that
|
|
46
49
|
* exiting the process right afterward does not truncate the output.
|
|
47
50
|
*
|
|
51
|
+
* A custom writer using `console.error()` can lose large piped output on
|
|
52
|
+
* affected Bun versions. See the Bun output warning on {@link run}.
|
|
53
|
+
*
|
|
48
54
|
* @default Writes to `process.stderr` with a trailing newline
|
|
49
55
|
*/
|
|
50
56
|
readonly stderr?: (text: string) => void;
|
|
51
57
|
/**
|
|
52
58
|
* Function used to exit the process on help/version display or parse error.
|
|
53
59
|
*
|
|
60
|
+
* This hook is synchronous and runs immediately after an output handler
|
|
61
|
+
* returns. With the default `process.exit()` handler, custom `stdout` and
|
|
62
|
+
* `stderr` handlers must finish writing synchronously before returning.
|
|
63
|
+
* The default exit handler also does not wait for writes queued by
|
|
64
|
+
* application code.
|
|
65
|
+
*
|
|
66
|
+
* To wait for asynchronous writes, record their completion promises and
|
|
67
|
+
* throw an exception carrying the exit code from `onExit`. Catch that
|
|
68
|
+
* exception outside the runner, await the recorded promises, then call
|
|
69
|
+
* `process.exit()` with that code.
|
|
70
|
+
* An arbitrary delay does not guarantee that output has been flushed.
|
|
71
|
+
*
|
|
54
72
|
* @default `process.exit`
|
|
55
73
|
*/
|
|
56
74
|
readonly onExit?: (exitCode: number) => never;
|
|
@@ -295,6 +313,24 @@ type AcceptExactOptionalRunOptions<TOptions> = [TOptions] extends [RunOptions |
|
|
|
295
313
|
* - Exit the process with appropriate codes on help or error
|
|
296
314
|
* - Format output according to terminal capabilities
|
|
297
315
|
*
|
|
316
|
+
* On affected Bun versions, importing `@optique/run` can cause large
|
|
317
|
+
* application `console.log()` output to be silently truncated when piped,
|
|
318
|
+
* even after successful parsing and natural process exit. This is
|
|
319
|
+
* [Bun issue #36419](https://github.com/oven-sh/bun/issues/36419), reported
|
|
320
|
+
* on macOS arm64 with Bun 1.3.14 and 1.4.2. Use `process.stdout.write()`
|
|
321
|
+
* instead of `console.log()` for application data, and `process.stderr.write()`
|
|
322
|
+
* instead of `console.error()` for diagnostics. Both console methods can lose
|
|
323
|
+
* large piped output. Let the process exit naturally. If explicit termination
|
|
324
|
+
* is necessary, wait for the completion callbacks of all pending stdout/stderr
|
|
325
|
+
* writes before calling `process.exit()`; a delay is not a flush guarantee. Waiting after `console.log()` or `console.error()` cannot
|
|
326
|
+
* recover dropped bytes.
|
|
327
|
+
*
|
|
328
|
+
* Setting `colors` and `maxWidth` explicitly does not avoid this Bun bug:
|
|
329
|
+
* importing `node:process`, which this module does, was enough to trigger it
|
|
330
|
+
* in Bun 1.3.14. The upstream fix was merged in
|
|
331
|
+
* [Bun PR #43868](https://github.com/oven-sh/bun/pull/43868); check whether
|
|
332
|
+
* your Bun release includes it.
|
|
333
|
+
*
|
|
298
334
|
* @template T The parser type being executed.
|
|
299
335
|
* @param parser The command-line parser to execute.
|
|
300
336
|
* @param options Configuration options for customizing behavior.
|
|
@@ -378,6 +414,8 @@ declare function run<T extends Parser<Mode, unknown, unknown>>(parser: T, option
|
|
|
378
414
|
* Use this when you know your parser is sync-only to get direct return values
|
|
379
415
|
* without Promise wrappers.
|
|
380
416
|
*
|
|
417
|
+
* See {@link run} for Bun's piped console output warning and workarounds.
|
|
418
|
+
*
|
|
381
419
|
* @template T The sync parser type being executed.
|
|
382
420
|
* @param parser The synchronous command-line parser to execute.
|
|
383
421
|
* @param options Configuration options for customizing behavior.
|
|
@@ -406,6 +444,8 @@ declare function runSync<T extends Parser<"sync", unknown, unknown>>(parser: T,
|
|
|
406
444
|
* Promise. Use this when working with parsers that may contain async
|
|
407
445
|
* value parsers.
|
|
408
446
|
*
|
|
447
|
+
* See {@link run} for Bun's piped console output warning and workarounds.
|
|
448
|
+
*
|
|
409
449
|
* @template T The parser type being executed.
|
|
410
450
|
* @param parser The command-line parser to execute.
|
|
411
451
|
* @param options Configuration options for customizing behavior.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/run",
|
|
3
|
-
"version": "1.0.12-dev.
|
|
3
|
+
"version": "1.0.12-dev.2703",
|
|
4
4
|
"description": "Type-safe combinatorial command-line interface parser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
},
|
|
71
71
|
"sideEffects": false,
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@optique/core": "1.0.12-dev.
|
|
73
|
+
"@optique/core": "1.0.12-dev.2703+3a9b5b8d"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/node": "^20.19.9",
|