command-stream 0.8.2 → 0.9.0
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/js/examples/01-basic-streaming.mjs +14 -0
- package/js/examples/02-async-iterator.mjs +9 -0
- package/js/examples/03-file-and-console.mjs +16 -0
- package/js/examples/04-claude-jq-pipe.mjs +16 -0
- package/js/examples/CI-DEBUG-README.md +138 -0
- package/js/examples/README-examples.mjs +111 -0
- package/js/examples/README.md +345 -0
- package/js/examples/STREAMING_INTERFACES_SUMMARY.md +116 -0
- package/js/examples/add-test-timeouts.js +107 -0
- package/js/examples/ansi-default-preserved.mjs +11 -0
- package/js/examples/ansi-global-config.mjs +12 -0
- package/js/examples/ansi-reset-default.mjs +12 -0
- package/js/examples/ansi-strip-utils.mjs +12 -0
- package/js/examples/baseline-child-process.mjs +23 -0
- package/js/examples/baseline-claude-test.mjs +47 -0
- package/js/examples/baseline-working.mjs +34 -0
- package/js/examples/capture-mirror-comparison.mjs +23 -0
- package/js/examples/capture-mirror-default.mjs +11 -0
- package/js/examples/capture-mirror-performance.mjs +16 -0
- package/js/examples/capture-mirror-show-only.mjs +16 -0
- package/js/examples/capture-mirror-silent-processing.mjs +16 -0
- package/js/examples/ci-debug-baseline-vs-library.mjs +265 -0
- package/js/examples/ci-debug-es-module-loading.mjs +184 -0
- package/js/examples/ci-debug-signal-handling.mjs +225 -0
- package/js/examples/ci-debug-stdout-buffering.mjs +94 -0
- package/js/examples/ci-debug-test-timeouts.mjs +259 -0
- package/js/examples/claude-exact-file-output.mjs +20 -0
- package/js/examples/claude-exact-jq.mjs +13 -0
- package/js/examples/claude-exact-streaming.mjs +13 -0
- package/js/examples/claude-jq-pipeline.mjs +13 -0
- package/js/examples/claude-json-stream.mjs +39 -0
- package/js/examples/claude-streaming-basic.mjs +99 -0
- package/js/examples/claude-streaming-demo.mjs +126 -0
- package/js/examples/claude-streaming-final.mjs +20 -0
- package/js/examples/cleanup-verification-test.mjs +115 -0
- package/js/examples/colors-buffer-processing.mjs +14 -0
- package/js/examples/colors-default-preserved.mjs +15 -0
- package/js/examples/colors-per-command-config.mjs +15 -0
- package/js/examples/colors-strip-ansi.mjs +13 -0
- package/js/examples/commandstream-jq.mjs +29 -0
- package/js/examples/commandstream-working.mjs +23 -0
- package/js/examples/comprehensive-streams-demo.mjs +121 -0
- package/js/examples/ctrl-c-concurrent-processes.mjs +20 -0
- package/js/examples/ctrl-c-long-running-command.mjs +20 -0
- package/js/examples/ctrl-c-real-system-command.mjs +17 -0
- package/js/examples/ctrl-c-sleep-command.mjs +17 -0
- package/js/examples/ctrl-c-stdin-forwarding.mjs +20 -0
- package/js/examples/ctrl-c-virtual-command.mjs +17 -0
- package/js/examples/debug-already-started.mjs +20 -0
- package/js/examples/debug-ansi-processing.mjs +42 -0
- package/js/examples/debug-basic-streaming.mjs +44 -0
- package/js/examples/debug-buildshellcommand.mjs +82 -0
- package/js/examples/debug-child-process.mjs +43 -0
- package/js/examples/debug-child-state.mjs +55 -0
- package/js/examples/debug-chunking.mjs +38 -0
- package/js/examples/debug-command-parsing.mjs +61 -0
- package/js/examples/debug-complete-consolidation.mjs +97 -0
- package/js/examples/debug-echo-args.mjs +22 -0
- package/js/examples/debug-emit-timing.mjs +28 -0
- package/js/examples/debug-end-event.mjs +56 -0
- package/js/examples/debug-errexit.mjs +16 -0
- package/js/examples/debug-event-emission.mjs +40 -0
- package/js/examples/debug-event-timing.mjs +67 -0
- package/js/examples/debug-event-vs-result.mjs +30 -0
- package/js/examples/debug-exact-command.mjs +28 -0
- package/js/examples/debug-exact-test-scenario.mjs +44 -0
- package/js/examples/debug-execution-path.mjs +27 -0
- package/js/examples/debug-exit-command.mjs +38 -0
- package/js/examples/debug-exit-virtual.mjs +54 -0
- package/js/examples/debug-finish-consolidation.mjs +44 -0
- package/js/examples/debug-force-cleanup.mjs +47 -0
- package/js/examples/debug-getter-basic.mjs +13 -0
- package/js/examples/debug-getter-direct.mjs +23 -0
- package/js/examples/debug-getter-internals.mjs +61 -0
- package/js/examples/debug-handler-detection.mjs +65 -0
- package/js/examples/debug-idempotent-finish.mjs +54 -0
- package/js/examples/debug-idempotent-kill.mjs +58 -0
- package/js/examples/debug-interpolation-individual.mjs +88 -0
- package/js/examples/debug-interpolation-issue.mjs +101 -0
- package/js/examples/debug-jq-streaming.mjs +57 -0
- package/js/examples/debug-jq-tty-colors.mjs +168 -0
- package/js/examples/debug-kill-cleanup.mjs +56 -0
- package/js/examples/debug-kill-method.mjs +33 -0
- package/js/examples/debug-listener-interference.mjs +38 -0
- package/js/examples/debug-listener-lifecycle.mjs +50 -0
- package/js/examples/debug-listener-timing.mjs +62 -0
- package/js/examples/debug-listeners-property.mjs +34 -0
- package/js/examples/debug-map-methods.mjs +39 -0
- package/js/examples/debug-not-awaited-cleanup.mjs +106 -0
- package/js/examples/debug-off-method.mjs +28 -0
- package/js/examples/debug-option-merging.mjs +17 -0
- package/js/examples/debug-options.mjs +36 -0
- package/js/examples/debug-output.mjs +25 -0
- package/js/examples/debug-pattern-matching.mjs +69 -0
- package/js/examples/debug-pipeline-cat.mjs +28 -0
- package/js/examples/debug-pipeline-cleanup.mjs +71 -0
- package/js/examples/debug-pipeline-error-detailed.mjs +78 -0
- package/js/examples/debug-pipeline-error.mjs +65 -0
- package/js/examples/debug-pipeline-issue.mjs +26 -0
- package/js/examples/debug-pipeline-method.mjs +22 -0
- package/js/examples/debug-pipeline-stream.mjs +66 -0
- package/js/examples/debug-pipeline.mjs +14 -0
- package/js/examples/debug-process-exit-trace.mjs +41 -0
- package/js/examples/debug-process-path.mjs +38 -0
- package/js/examples/debug-property-check.mjs +29 -0
- package/js/examples/debug-resource-cleanup.mjs +83 -0
- package/js/examples/debug-shell-args.mjs +103 -0
- package/js/examples/debug-sigint-child-handler.mjs +44 -0
- package/js/examples/debug-sigint-forwarding.mjs +61 -0
- package/js/examples/debug-sigint-handler-install.mjs +79 -0
- package/js/examples/debug-sigint-handler-order.mjs +85 -0
- package/js/examples/debug-sigint-listeners.mjs +48 -0
- package/js/examples/debug-sigint-start-pattern.mjs +62 -0
- package/js/examples/debug-sigint-timer.mjs +40 -0
- package/js/examples/debug-simple-command.mjs +49 -0
- package/js/examples/debug-simple-getter.mjs +30 -0
- package/js/examples/debug-simple.mjs +39 -0
- package/js/examples/debug-simplified-finished.mjs +102 -0
- package/js/examples/debug-stack-overflow.mjs +25 -0
- package/js/examples/debug-stdin-simple.mjs +28 -0
- package/js/examples/debug-stdin.mjs +28 -0
- package/js/examples/debug-stream-emitter-isolated.mjs +45 -0
- package/js/examples/debug-stream-emitter.mjs +25 -0
- package/js/examples/debug-stream-events.mjs +70 -0
- package/js/examples/debug-stream-generator.mjs +23 -0
- package/js/examples/debug-stream-getter-issue.mjs +37 -0
- package/js/examples/debug-stream-getter.mjs +19 -0
- package/js/examples/debug-stream-internals.mjs +64 -0
- package/js/examples/debug-stream-method.mjs +46 -0
- package/js/examples/debug-stream-object.mjs +58 -0
- package/js/examples/debug-stream-properties.mjs +37 -0
- package/js/examples/debug-stream-timing.mjs +28 -0
- package/js/examples/debug-streaming.mjs +24 -0
- package/js/examples/debug-test-isolation.mjs +54 -0
- package/js/examples/debug-test-state.mjs +27 -0
- package/js/examples/debug-user-sigint.mjs +19 -0
- package/js/examples/debug-virtual-disable.mjs +21 -0
- package/js/examples/debug-virtual-vs-real.mjs +68 -0
- package/js/examples/debug-with-trace.mjs +23 -0
- package/js/examples/debug_parent_stream.mjs +22 -0
- package/js/examples/emulate-claude-stream.mjs +30 -0
- package/js/examples/emulated-streaming-direct.mjs +22 -0
- package/js/examples/emulated-streaming-jq-pipe.mjs +22 -0
- package/js/examples/emulated-streaming-sh-pipe.mjs +23 -0
- package/js/examples/events-build-process.mjs +73 -0
- package/js/examples/events-concurrent-streams.mjs +51 -0
- package/js/examples/events-error-handling.mjs +59 -0
- package/js/examples/events-file-monitoring.mjs +66 -0
- package/js/examples/events-interactive-simulation.mjs +69 -0
- package/js/examples/events-log-processing.mjs +72 -0
- package/js/examples/events-network-monitoring.mjs +68 -0
- package/js/examples/events-ping-basic.mjs +37 -0
- package/js/examples/events-progress-tracking.mjs +55 -0
- package/js/examples/events-stdin-input.mjs +34 -0
- package/js/examples/example-ansi-ls.mjs +39 -0
- package/js/examples/example-top.mjs +27 -0
- package/js/examples/final-ping-stdin-proof.mjs +88 -0
- package/js/examples/final-test-shell-operators.mjs +123 -0
- package/js/examples/final-working-examples.mjs +162 -0
- package/js/examples/gh-auth-test.mjs +103 -0
- package/js/examples/gh-delete-hang-test.mjs +79 -0
- package/js/examples/gh-gist-creation-test.mjs +276 -0
- package/js/examples/gh-gist-minimal-test.mjs +89 -0
- package/js/examples/gh-hang-exact-original.mjs +83 -0
- package/js/examples/gh-hang-reproduction.mjs +151 -0
- package/js/examples/gh-hang-test-with-redirect.mjs +45 -0
- package/js/examples/gh-hang-test-without-redirect.mjs +43 -0
- package/js/examples/gh-minimal-hang-check.mjs +33 -0
- package/js/examples/gh-operations-with-cd.mjs +187 -0
- package/js/examples/gh-output-test.mjs +102 -0
- package/js/examples/gh-reproduce-hang.mjs +41 -0
- package/js/examples/git-operations-with-cd.mjs +186 -0
- package/js/examples/interactive-math-calc.mjs +45 -0
- package/js/examples/interactive-top-fixed.mjs +25 -0
- package/js/examples/interactive-top-improved.mjs +72 -0
- package/js/examples/interactive-top-pty-logging.mjs +69 -0
- package/js/examples/interactive-top-pty.mjs +27 -0
- package/js/examples/interactive-top-with-logging.mjs +56 -0
- package/js/examples/interactive-top.mjs +29 -0
- package/js/examples/jq-color-demo.mjs +53 -0
- package/js/examples/jq-colors-streaming.mjs +42 -0
- package/js/examples/manual-ctrl-c-test.mjs +50 -0
- package/js/examples/methods-multiple-options.mjs +25 -0
- package/js/examples/methods-run-basic.mjs +10 -0
- package/js/examples/methods-start-basic.mjs +10 -0
- package/js/examples/node-compat-data-events.mjs +36 -0
- package/js/examples/node-compat-readable-event.mjs +29 -0
- package/js/examples/node-compat-small-buffer.mjs +33 -0
- package/js/examples/options-capture-false.mjs +12 -0
- package/js/examples/options-combined-settings.mjs +13 -0
- package/js/examples/options-custom-input.mjs +16 -0
- package/js/examples/options-default-behavior.mjs +10 -0
- package/js/examples/options-maximum-performance.mjs +15 -0
- package/js/examples/options-mirror-false.mjs +10 -0
- package/js/examples/options-performance-mode.mjs +13 -0
- package/js/examples/options-performance-optimization.mjs +14 -0
- package/js/examples/options-run-alias-demo.mjs +15 -0
- package/js/examples/options-run-alias.mjs +10 -0
- package/js/examples/options-silent-execution.mjs +14 -0
- package/js/examples/options-streaming-capture.mjs +24 -0
- package/js/examples/options-streaming-multiple.mjs +35 -0
- package/js/examples/options-streaming-silent.mjs +21 -0
- package/js/examples/options-streaming-stdin.mjs +21 -0
- package/js/examples/ping-streaming-filtered.mjs +22 -0
- package/js/examples/ping-streaming-interruptible.mjs +47 -0
- package/js/examples/ping-streaming-silent.mjs +24 -0
- package/js/examples/ping-streaming-simple.mjs +13 -0
- package/js/examples/ping-streaming-statistics.mjs +49 -0
- package/js/examples/ping-streaming-timestamps.mjs +22 -0
- package/js/examples/ping-streaming.mjs +48 -0
- package/js/examples/prove-ping-stdin-limitation.mjs +94 -0
- package/js/examples/readme-example.mjs +39 -0
- package/js/examples/realtime-json-stream.mjs +143 -0
- package/js/examples/reliable-stdin-commands.mjs +135 -0
- package/js/examples/reproduce-issue-135-v2.mjs +15 -0
- package/js/examples/reproduce-issue-135.mjs +17 -0
- package/js/examples/shell-cd-behavior.mjs +88 -0
- package/js/examples/sigint-forwarding-test.mjs +60 -0
- package/js/examples/sigint-handler-test.mjs +72 -0
- package/js/examples/simple-async-test.mjs +49 -0
- package/js/examples/simple-claude-test.mjs +17 -0
- package/js/examples/simple-event-test.mjs +33 -0
- package/js/examples/simple-jq-streaming.mjs +48 -0
- package/js/examples/simple-stream-demo.mjs +35 -0
- package/js/examples/simple-test-sleep.js +30 -0
- package/js/examples/simple-working-stdin.mjs +30 -0
- package/js/examples/streaming-behavior-test.mjs +116 -0
- package/js/examples/streaming-direct-command.mjs +21 -0
- package/js/examples/streaming-filtered-output.mjs +33 -0
- package/js/examples/streaming-grep-pipeline.mjs +21 -0
- package/js/examples/streaming-interactive-stdin.mjs +24 -0
- package/js/examples/streaming-jq-pipeline.mjs +23 -0
- package/js/examples/streaming-multistage-pipeline.mjs +23 -0
- package/js/examples/streaming-pipes-event-pattern.mjs +27 -0
- package/js/examples/streaming-pipes-multistage.mjs +22 -0
- package/js/examples/streaming-pipes-realtime-jq.mjs +23 -0
- package/js/examples/streaming-progress-tracking.mjs +34 -0
- package/js/examples/streaming-reusable-configs.mjs +52 -0
- package/js/examples/streaming-silent-capture.mjs +20 -0
- package/js/examples/streaming-test-simple.mjs +70 -0
- package/js/examples/streaming-virtual-pipeline.mjs +18 -0
- package/js/examples/syntax-basic-comparison.mjs +31 -0
- package/js/examples/syntax-basic-options.mjs +12 -0
- package/js/examples/syntax-combined-options.mjs +19 -0
- package/js/examples/syntax-command-chaining.mjs +12 -0
- package/js/examples/syntax-custom-directory.mjs +10 -0
- package/js/examples/syntax-custom-environment.mjs +13 -0
- package/js/examples/syntax-custom-stdin.mjs +10 -0
- package/js/examples/syntax-mixed-regular.mjs +11 -0
- package/js/examples/syntax-mixed-usage.mjs +15 -0
- package/js/examples/syntax-multiple-listeners.mjs +87 -0
- package/js/examples/syntax-piping-comparison.mjs +32 -0
- package/js/examples/syntax-reusable-config.mjs +16 -0
- package/js/examples/syntax-reusable-configs.mjs +21 -0
- package/js/examples/syntax-silent-operations.mjs +10 -0
- package/js/examples/syntax-stdin-option.mjs +12 -0
- package/js/examples/temp-sigint-test.mjs +21 -0
- package/js/examples/test-actual-buildshell.mjs +44 -0
- package/js/examples/test-async-streams-working.mjs +102 -0
- package/js/examples/test-async-streams.mjs +90 -0
- package/js/examples/test-auth-parse.mjs +74 -0
- package/js/examples/test-auto-quoting.mjs +57 -0
- package/js/examples/test-auto-start-fix.mjs +95 -0
- package/js/examples/test-baseline-sigint.mjs +38 -0
- package/js/examples/test-buffer-behavior.mjs +39 -0
- package/js/examples/test-buffers-simple.mjs +35 -0
- package/js/examples/test-bun-specific-issue.mjs +106 -0
- package/js/examples/test-bun-streaming.mjs +81 -0
- package/js/examples/test-cat-direct.mjs +41 -0
- package/js/examples/test-cat-pipe.mjs +34 -0
- package/js/examples/test-cd-behavior.mjs +42 -0
- package/js/examples/test-child-process-timing.mjs +53 -0
- package/js/examples/test-child-sigint-handler.mjs +62 -0
- package/js/examples/test-cleanup-simple.mjs +21 -0
- package/js/examples/test-comprehensive-tracing.mjs +58 -0
- package/js/examples/test-correct-space-handling.mjs +46 -0
- package/js/examples/test-ctrl-c-debug.mjs +44 -0
- package/js/examples/test-ctrl-c-inherit.mjs +30 -0
- package/js/examples/test-ctrl-c-sleep.mjs +31 -0
- package/js/examples/test-ctrl-c.mjs +17 -0
- package/js/examples/test-debug-new-options.mjs +55 -0
- package/js/examples/test-debug-pty.mjs +49 -0
- package/js/examples/test-debug-tee.mjs +38 -0
- package/js/examples/test-debug.mjs +25 -0
- package/js/examples/test-direct-jq.mjs +47 -0
- package/js/examples/test-direct-pipe-reading.mjs +119 -0
- package/js/examples/test-direct-pipe.sh +28 -0
- package/js/examples/test-double-quoting-prevention.mjs +138 -0
- package/js/examples/test-edge-cases-quoting.mjs +89 -0
- package/js/examples/test-events.mjs +37 -0
- package/js/examples/test-explicit-stdio.mjs +51 -0
- package/js/examples/test-final-streaming.mjs +71 -0
- package/js/examples/test-fix.mjs +71 -0
- package/js/examples/test-incremental-streaming.mjs +46 -0
- package/js/examples/test-individual-spawn.mjs +35 -0
- package/js/examples/test-inherit-stdout-not-stdin.mjs +133 -0
- package/js/examples/test-injection-protection.mjs +77 -0
- package/js/examples/test-interactive-streaming.mjs +140 -0
- package/js/examples/test-interactive-top.md +24 -0
- package/js/examples/test-interactive.mjs +17 -0
- package/js/examples/test-interpolation.mjs +14 -0
- package/js/examples/test-interrupt.mjs +40 -0
- package/js/examples/test-issue-135-comprehensive.mjs +41 -0
- package/js/examples/test-issue12-detailed.mjs +89 -0
- package/js/examples/test-issue12-exact.mjs +33 -0
- package/js/examples/test-jq-color.mjs +57 -0
- package/js/examples/test-jq-colors.mjs +41 -0
- package/js/examples/test-jq-compact.mjs +33 -0
- package/js/examples/test-jq-native.sh +10 -0
- package/js/examples/test-jq-pipeline-behavior.mjs +80 -0
- package/js/examples/test-jq-realtime.mjs +40 -0
- package/js/examples/test-manual-start.mjs +54 -0
- package/js/examples/test-mixed-quoting.mjs +88 -0
- package/js/examples/test-multi-stream.mjs +50 -0
- package/js/examples/test-multistage-debug.mjs +44 -0
- package/js/examples/test-native-spawn-vs-command-stream.mjs +154 -0
- package/js/examples/test-no-parse-pipeline.mjs +33 -0
- package/js/examples/test-non-virtual.mjs +52 -0
- package/js/examples/test-operators.mjs +53 -0
- package/js/examples/test-parent-continues.mjs +44 -0
- package/js/examples/test-path-interpolation.mjs +86 -0
- package/js/examples/test-ping-kill-and-stdin.mjs +98 -0
- package/js/examples/test-ping.mjs +12 -0
- package/js/examples/test-pty-spawn.mjs +101 -0
- package/js/examples/test-pty.mjs +38 -0
- package/js/examples/test-quote-behavior-summary.mjs +110 -0
- package/js/examples/test-quote-edge-cases.mjs +69 -0
- package/js/examples/test-quote-parsing.mjs +23 -0
- package/js/examples/test-raw-function.mjs +153 -0
- package/js/examples/test-raw-streaming.mjs +47 -0
- package/js/examples/test-readme-examples.mjs +142 -0
- package/js/examples/test-real-cat.mjs +28 -0
- package/js/examples/test-real-commands.mjs +21 -0
- package/js/examples/test-real-shell.mjs +31 -0
- package/js/examples/test-real-stdin-commands.mjs +160 -0
- package/js/examples/test-runner-batched.mjs +98 -0
- package/js/examples/test-runner-simple.mjs +80 -0
- package/js/examples/test-runner.mjs +67 -0
- package/js/examples/test-scope-parse.mjs +31 -0
- package/js/examples/test-sh-pipeline.mjs +24 -0
- package/js/examples/test-shell-detection.mjs +71 -0
- package/js/examples/test-shell-parser.mjs +37 -0
- package/js/examples/test-sigint-behavior.mjs +241 -0
- package/js/examples/test-sigint-handling.sh +14 -0
- package/js/examples/test-simple-pipe.mjs +12 -0
- package/js/examples/test-simple-streaming.mjs +32 -0
- package/js/examples/test-sleep-stdin.js +27 -0
- package/js/examples/test-sleep.mjs +56 -0
- package/js/examples/test-smart-quoting.mjs +180 -0
- package/js/examples/test-spaces-in-path.mjs +48 -0
- package/js/examples/test-special-chars-quoting.mjs +54 -0
- package/js/examples/test-stdin-after-start.mjs +39 -0
- package/js/examples/test-stdin-simple.mjs +67 -0
- package/js/examples/test-stdin-timing.mjs +74 -0
- package/js/examples/test-stdio-combinations.mjs +124 -0
- package/js/examples/test-stream-access.mjs +84 -0
- package/js/examples/test-stream-cleanup.mjs +27 -0
- package/js/examples/test-stream-readers.mjs +152 -0
- package/js/examples/test-streaming-final.mjs +57 -0
- package/js/examples/test-streaming-interfaces.mjs +141 -0
- package/js/examples/test-streaming-timing.mjs +27 -0
- package/js/examples/test-streaming.mjs +32 -0
- package/js/examples/test-streams-stdin-comprehensive.mjs +134 -0
- package/js/examples/test-streams-stdin-ctrl-c.mjs +96 -0
- package/js/examples/test-template-literal.mjs +26 -0
- package/js/examples/test-template-vs-interpolation.mjs +49 -0
- package/js/examples/test-timing.mjs +41 -0
- package/js/examples/test-top-inherit-stdout-stdin-control.mjs +123 -0
- package/js/examples/test-top-quit-stdin.mjs +118 -0
- package/js/examples/test-trace-option.mjs +21 -0
- package/js/examples/test-user-double-quotes.mjs +36 -0
- package/js/examples/test-user-single-quotes.mjs +36 -0
- package/js/examples/test-verbose.mjs +18 -0
- package/js/examples/test-verbose2.mjs +32 -0
- package/js/examples/test-virtual-streaming.mjs +125 -0
- package/js/examples/test-waiting-command.mjs +52 -0
- package/js/examples/test-waiting-commands.mjs +83 -0
- package/js/examples/test-watch-mode.mjs +104 -0
- package/js/examples/test-yes-cancellation.mjs +26 -0
- package/js/examples/test-yes-detailed.mjs +58 -0
- package/js/examples/test-yes-trace.mjs +28 -0
- package/js/examples/trace-abort-controller.mjs +30 -0
- package/js/examples/trace-error-handling.mjs +22 -0
- package/js/examples/trace-pipeline-command.mjs +22 -0
- package/js/examples/trace-signal-handling.mjs +35 -0
- package/js/examples/trace-simple-command.mjs +18 -0
- package/js/examples/trace-stderr-output.mjs +22 -0
- package/js/examples/verify-fix-both-runtimes.mjs +73 -0
- package/js/examples/verify-issue12-fixed.mjs +78 -0
- package/js/examples/which-command-common-commands.mjs +19 -0
- package/js/examples/which-command-gh-test.mjs +23 -0
- package/js/examples/which-command-nonexistent.mjs +20 -0
- package/js/examples/which-command-system-comparison.mjs +28 -0
- package/js/examples/working-example.mjs +13 -0
- package/js/examples/working-stdin-examples.mjs +138 -0
- package/js/examples/working-streaming-demo.mjs +49 -0
- package/{src → js/src}/$.mjs +20 -4
- package/{src → js/src}/$.utils.mjs +14 -2
- package/js/tests/$.features.test.mjs +283 -0
- package/js/tests/$.test.mjs +935 -0
- package/js/tests/builtin-commands.test.mjs +387 -0
- package/js/tests/bun-shell-path-fix.test.mjs +115 -0
- package/js/tests/bun.features.test.mjs +189 -0
- package/js/tests/cd-virtual-command.test.mjs +622 -0
- package/js/tests/cleanup-verification.test.mjs +127 -0
- package/js/tests/ctrl-c-baseline.test.mjs +207 -0
- package/js/tests/ctrl-c-basic.test.mjs +220 -0
- package/js/tests/ctrl-c-library.test.mjs +197 -0
- package/js/tests/ctrl-c-signal.test.mjs +915 -0
- package/js/tests/examples.test.mjs +252 -0
- package/js/tests/execa.features.test.mjs +198 -0
- package/js/tests/gh-commands.test.mjs +164 -0
- package/js/tests/gh-gist-operations.test.mjs +221 -0
- package/js/tests/git-gh-cd.test.mjs +466 -0
- package/js/tests/interactive-option.test.mjs +114 -0
- package/js/tests/interactive-streaming.test.mjs +307 -0
- package/js/tests/issue-135-final.test.mjs +58 -0
- package/js/tests/jq-color-behavior.test.mjs +140 -0
- package/js/tests/jq.test.mjs +318 -0
- package/js/tests/options-examples.test.mjs +106 -0
- package/js/tests/options-syntax.test.mjs +112 -0
- package/js/tests/path-interpolation.test.mjs +412 -0
- package/js/tests/pipe.test.mjs +291 -0
- package/js/tests/raw-function.test.mjs +266 -0
- package/js/tests/readme-examples.test.mjs +427 -0
- package/js/tests/resource-cleanup-internals.test.mjs +669 -0
- package/js/tests/shell-settings.test.mjs +279 -0
- package/js/tests/sigint-cleanup-isolated.test.mjs +151 -0
- package/js/tests/sigint-cleanup.test.mjs +118 -0
- package/js/tests/start-run-edge-cases.test.mjs +152 -0
- package/js/tests/start-run-options.test.mjs +181 -0
- package/js/tests/stderr-output-handling.test.mjs +279 -0
- package/js/tests/streaming-interfaces.test.mjs +194 -0
- package/js/tests/sync.test.mjs +297 -0
- package/js/tests/system-pipe.test.mjs +226 -0
- package/js/tests/test-cleanup.mjs +200 -0
- package/js/tests/test-helper-fixed.mjs +148 -0
- package/js/tests/test-helper-v2.mjs +118 -0
- package/js/tests/test-helper.mjs +171 -0
- package/js/tests/test-sigint-child.js +15 -0
- package/js/tests/text-method.test.mjs +225 -0
- package/js/tests/virtual.test.mjs +364 -0
- package/js/tests/yes-command-cleanup.test.mjs +208 -0
- package/js/tests/zx.features.test.mjs +233 -0
- package/package.json +13 -12
- package/rust/Cargo.lock +947 -0
- package/rust/Cargo.toml +47 -0
- package/rust/src/commands/basename.rs +69 -0
- package/rust/src/commands/cat.rs +123 -0
- package/rust/src/commands/cd.rs +67 -0
- package/rust/src/commands/cp.rs +187 -0
- package/rust/src/commands/dirname.rs +57 -0
- package/rust/src/commands/echo.rs +73 -0
- package/rust/src/commands/env.rs +33 -0
- package/rust/src/commands/exit.rs +36 -0
- package/rust/src/commands/false.rs +24 -0
- package/rust/src/commands/ls.rs +182 -0
- package/rust/src/commands/mkdir.rs +98 -0
- package/rust/src/commands/mod.rs +200 -0
- package/rust/src/commands/mv.rs +180 -0
- package/rust/src/commands/pwd.rs +28 -0
- package/rust/src/commands/rm.rs +150 -0
- package/rust/src/commands/seq.rs +179 -0
- package/rust/src/commands/sleep.rs +97 -0
- package/rust/src/commands/test.rs +204 -0
- package/rust/src/commands/touch.rs +99 -0
- package/rust/src/commands/true.rs +24 -0
- package/rust/src/commands/which.rs +87 -0
- package/rust/src/commands/yes.rs +99 -0
- package/rust/src/lib.rs +492 -0
- package/rust/src/main.rs +37 -0
- package/rust/src/shell_parser.rs +565 -0
- package/rust/src/utils.rs +335 -0
- package/rust/tests/builtin_commands.rs +549 -0
- package/rust/tests/process_runner.rs +286 -0
- package/rust/tests/shell_parser.rs +296 -0
- package/rust/tests/utils.rs +282 -0
- package/rust/tests/virtual_commands.rs +199 -0
- /package/{src → js/src}/commands/$.basename.mjs +0 -0
- /package/{src → js/src}/commands/$.cat.mjs +0 -0
- /package/{src → js/src}/commands/$.cd.mjs +0 -0
- /package/{src → js/src}/commands/$.cp.mjs +0 -0
- /package/{src → js/src}/commands/$.dirname.mjs +0 -0
- /package/{src → js/src}/commands/$.echo.mjs +0 -0
- /package/{src → js/src}/commands/$.env.mjs +0 -0
- /package/{src → js/src}/commands/$.exit.mjs +0 -0
- /package/{src → js/src}/commands/$.false.mjs +0 -0
- /package/{src → js/src}/commands/$.ls.mjs +0 -0
- /package/{src → js/src}/commands/$.mkdir.mjs +0 -0
- /package/{src → js/src}/commands/$.mv.mjs +0 -0
- /package/{src → js/src}/commands/$.pwd.mjs +0 -0
- /package/{src → js/src}/commands/$.rm.mjs +0 -0
- /package/{src → js/src}/commands/$.seq.mjs +0 -0
- /package/{src → js/src}/commands/$.sleep.mjs +0 -0
- /package/{src → js/src}/commands/$.test.mjs +0 -0
- /package/{src → js/src}/commands/$.touch.mjs +0 -0
- /package/{src → js/src}/commands/$.true.mjs +0 -0
- /package/{src → js/src}/commands/$.which.mjs +0 -0
- /package/{src → js/src}/commands/$.yes.mjs +0 -0
- /package/{src → js/src}/shell-parser.mjs +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Basic streaming example - shows real-time chunk processing
|
|
3
|
+
import { $ } from '../src/$.mjs';
|
|
4
|
+
|
|
5
|
+
let chunkCount = 0;
|
|
6
|
+
|
|
7
|
+
$`claude "Count from 1 to 3 briefly"`
|
|
8
|
+
.on('data', (chunk) => {
|
|
9
|
+
console.log(`Chunk ${++chunkCount}: ${chunk.data.toString().trim()}`);
|
|
10
|
+
})
|
|
11
|
+
.on('end', (result) =>
|
|
12
|
+
console.log(`Done! ${chunkCount} chunks, exit: ${result.code}`)
|
|
13
|
+
)
|
|
14
|
+
.start();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Async iterator pattern - process chunks as they arrive
|
|
3
|
+
import { $ } from '../src/$.mjs';
|
|
4
|
+
|
|
5
|
+
console.log('Using async iteration:');
|
|
6
|
+
|
|
7
|
+
for await (const chunk of $`claude "List 3 colors"`.stream()) {
|
|
8
|
+
console.log(`→ ${chunk.data.toString().trim()}`);
|
|
9
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Stream to both console and file simultaneously
|
|
3
|
+
import { $ } from '../src/$.mjs';
|
|
4
|
+
import { appendFileSync } from 'fs';
|
|
5
|
+
|
|
6
|
+
const logFile = 'stream-output.log';
|
|
7
|
+
let chunks = 0;
|
|
8
|
+
|
|
9
|
+
$`claude "Say hello 3 times"`
|
|
10
|
+
.on('data', (chunk) => {
|
|
11
|
+
const data = chunk.data.toString();
|
|
12
|
+
console.log(`Console: ${data.trim()}`);
|
|
13
|
+
appendFileSync(logFile, `Chunk ${++chunks}: ${data}`);
|
|
14
|
+
})
|
|
15
|
+
.on('end', () => console.log(`Saved ${chunks} chunks to ${logFile}`))
|
|
16
|
+
.start();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Claude output piped to jq for JSON processing
|
|
3
|
+
import { $ } from '../src/$.mjs';
|
|
4
|
+
|
|
5
|
+
console.log('Claude → jq pipeline:');
|
|
6
|
+
|
|
7
|
+
// Ask Claude for JSON output and pipe to jq
|
|
8
|
+
$`claude "Output a simple JSON object with name and age fields" --output-format json`
|
|
9
|
+
.pipe($`jq -r '.name'`)
|
|
10
|
+
.on('data', (chunk) => {
|
|
11
|
+
console.log(`jq result: ${chunk.data.toString().trim()}`);
|
|
12
|
+
})
|
|
13
|
+
.on('end', (result) => {
|
|
14
|
+
console.log(`Pipeline complete, exit: ${result.code}`);
|
|
15
|
+
})
|
|
16
|
+
.start();
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# CI Debugging Examples
|
|
2
|
+
|
|
3
|
+
This directory contains examples for debugging common issues that occur in CI environments when testing command execution libraries.
|
|
4
|
+
|
|
5
|
+
## Common CI Issues and Solutions
|
|
6
|
+
|
|
7
|
+
### 1. Stdout Buffering (`ci-debug-stdout-buffering.mjs`)
|
|
8
|
+
|
|
9
|
+
**Problem**: Output doesn't appear immediately in CI (non-TTY environments) due to stdout buffering.
|
|
10
|
+
|
|
11
|
+
**Solution**: Force stdout flush when not in TTY mode.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
node js/examples/ci-debug-stdout-buffering.mjs
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### 2. ES Module Loading Failures (`ci-debug-es-module-loading.mjs`)
|
|
18
|
+
|
|
19
|
+
**Problem**: Child processes with ES module imports fail immediately with SIGINT in CI.
|
|
20
|
+
|
|
21
|
+
**Solution**: Use different module loading strategies or fallback to shell commands.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
node js/examples/ci-debug-es-module-loading.mjs
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 3. Signal Handling (`ci-debug-signal-handling.mjs`)
|
|
28
|
+
|
|
29
|
+
**Problem**: SIGINT/SIGTERM signals behave differently in CI, especially with process groups.
|
|
30
|
+
|
|
31
|
+
**Solution**: Proper signal forwarding and environment-aware cleanup strategies.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
node js/examples/ci-debug-signal-handling.mjs
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 4. Test Timeouts (`ci-debug-test-timeouts.mjs`)
|
|
38
|
+
|
|
39
|
+
**Problem**: Tests hang indefinitely without proper timeout configuration.
|
|
40
|
+
|
|
41
|
+
**Solution**: Add explicit timeouts to all tests and implement timeout strategies.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
node js/examples/ci-debug-test-timeouts.mjs
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 5. Baseline vs Library Testing (`ci-debug-baseline-vs-library.mjs`)
|
|
48
|
+
|
|
49
|
+
**Problem**: Need to determine if failures are due to the library or underlying Node.js behavior.
|
|
50
|
+
|
|
51
|
+
**Solution**: Test both raw spawn and library functionality for comparison.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
node js/examples/ci-debug-baseline-vs-library.mjs
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Quick Debugging Checklist
|
|
58
|
+
|
|
59
|
+
When tests fail in CI but pass locally:
|
|
60
|
+
|
|
61
|
+
1. **Check stdout buffering**: Is output being buffered in non-TTY mode?
|
|
62
|
+
2. **Check module loading**: Are ES modules failing to load in child processes?
|
|
63
|
+
3. **Check signal handling**: Are signals being properly forwarded?
|
|
64
|
+
4. **Check timeouts**: Do all tests have appropriate timeouts?
|
|
65
|
+
5. **Check environment**: What's different between CI and local (TTY, env vars, etc.)?
|
|
66
|
+
|
|
67
|
+
## Environment Detection
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
const isCI = process.env.CI === 'true';
|
|
71
|
+
const isGitHubActions = process.env.GITHUB_ACTIONS === 'true';
|
|
72
|
+
const isTTY = process.stdout.isTTY;
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Common Fixes
|
|
76
|
+
|
|
77
|
+
### Force Stdout Flush
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
process.stdout.write('output\n');
|
|
81
|
+
if (!process.stdout.isTTY) {
|
|
82
|
+
process.stdout.write('', () => {}); // Force flush
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Add Test Timeouts (Bun)
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
test('my test', async () => {
|
|
90
|
+
// test code
|
|
91
|
+
}, 30000); // 30 second timeout
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Fallback to Shell Commands
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
// Instead of spawning Node with ES modules
|
|
98
|
+
spawn('sh', ['-c', 'echo "test"'], { stdio: 'inherit' });
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Proper Signal Cleanup
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
const cleanup = () => {
|
|
105
|
+
children.forEach((child) => child.kill('SIGTERM'));
|
|
106
|
+
};
|
|
107
|
+
process.on('SIGINT', cleanup);
|
|
108
|
+
process.on('SIGTERM', cleanup);
|
|
109
|
+
process.on('exit', cleanup);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Running All CI Debug Examples
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Run all CI debugging examples
|
|
116
|
+
for f in js/examples/ci-debug-*.mjs; do
|
|
117
|
+
echo "Running $f..."
|
|
118
|
+
node "$f"
|
|
119
|
+
echo ""
|
|
120
|
+
done
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Tips for CI Testing
|
|
124
|
+
|
|
125
|
+
1. **Always add timeouts** to prevent infinite hangs
|
|
126
|
+
2. **Use environment detection** to adjust behavior for CI
|
|
127
|
+
3. **Test both baseline and library** to isolate issues
|
|
128
|
+
4. **Add extensive logging** with timestamps in CI mode
|
|
129
|
+
5. **Handle signals properly** with cleanup on exit
|
|
130
|
+
6. **Force output flushing** in non-TTY environments
|
|
131
|
+
7. **Use simple shell commands** as fallback when ES modules fail
|
|
132
|
+
|
|
133
|
+
## Related Test Files
|
|
134
|
+
|
|
135
|
+
- `tests/ctrl-c-baseline.test.mjs` - Baseline spawn tests
|
|
136
|
+
- `tests/ctrl-c-library.test.mjs` - Library-specific tests
|
|
137
|
+
- `tests/ctrl-c-signal.test.mjs` - Signal handling tests
|
|
138
|
+
- `tests/cleanup-verification.test.mjs` - Resource cleanup tests
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Examples for README - using manual timing approach until async streams are perfected
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { $ } from '../src/$.mjs';
|
|
8
|
+
|
|
9
|
+
console.log('📖 README Examples - Streaming Interfaces');
|
|
10
|
+
console.log('='.repeat(50));
|
|
11
|
+
|
|
12
|
+
async function readmeExamples() {
|
|
13
|
+
try {
|
|
14
|
+
console.log('\\n✅ EXAMPLE 1: Basic stdin control with manual timing');
|
|
15
|
+
console.log('─'.repeat(30));
|
|
16
|
+
|
|
17
|
+
const catCmd = $`cat`;
|
|
18
|
+
|
|
19
|
+
// Start the process explicitly
|
|
20
|
+
catCmd.start({
|
|
21
|
+
mode: 'async',
|
|
22
|
+
stdin: 'pipe',
|
|
23
|
+
stdout: 'pipe',
|
|
24
|
+
stderr: 'pipe',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Wait for process to spawn
|
|
28
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
29
|
+
|
|
30
|
+
// Now access stdin directly
|
|
31
|
+
const stdin = catCmd.child ? catCmd.child.stdin : null;
|
|
32
|
+
console.log('stdin available:', !!stdin);
|
|
33
|
+
|
|
34
|
+
if (stdin) {
|
|
35
|
+
stdin.write('Hello from stdin!\\n');
|
|
36
|
+
stdin.write('Multiple lines work!\\n');
|
|
37
|
+
stdin.end();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const result = await catCmd;
|
|
41
|
+
console.log('Output:', JSON.stringify(result.stdout));
|
|
42
|
+
|
|
43
|
+
console.log('\\n✅ EXAMPLE 2: Kill method for network commands');
|
|
44
|
+
console.log('─'.repeat(30));
|
|
45
|
+
|
|
46
|
+
const pingCmd = $`ping 8.8.8.8`;
|
|
47
|
+
|
|
48
|
+
// Start monitoring output
|
|
49
|
+
pingCmd.streams.stdout; // Auto-start
|
|
50
|
+
|
|
51
|
+
// Kill after 1 second since ping ignores stdin
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
console.log('Killing ping...');
|
|
54
|
+
pingCmd.kill();
|
|
55
|
+
}, 1000);
|
|
56
|
+
|
|
57
|
+
const pingResult = await pingCmd;
|
|
58
|
+
console.log('Ping stopped with code:', pingResult.code);
|
|
59
|
+
console.log('Captured output length:', pingResult.stdout.length);
|
|
60
|
+
|
|
61
|
+
console.log('\\n✅ EXAMPLE 3: Using buffers and strings interfaces');
|
|
62
|
+
console.log('─'.repeat(30));
|
|
63
|
+
|
|
64
|
+
// Using buffers interface
|
|
65
|
+
const bufferCmd = $`echo "Binary data"`;
|
|
66
|
+
const buffer = await bufferCmd.buffers.stdout;
|
|
67
|
+
console.log('Buffer result:', buffer.toString());
|
|
68
|
+
|
|
69
|
+
// Using strings interface
|
|
70
|
+
const stringCmd = $`echo "Text data"`;
|
|
71
|
+
const text = await stringCmd.strings.stdout;
|
|
72
|
+
console.log('String result:', JSON.stringify(text.trim()));
|
|
73
|
+
|
|
74
|
+
console.log('\\n✅ EXAMPLE 4: Mixed stdout/stderr');
|
|
75
|
+
console.log('─'.repeat(30));
|
|
76
|
+
|
|
77
|
+
const mixedCmd = $`sh -c 'echo "stdout" && echo "stderr" >&2'`;
|
|
78
|
+
const [stdout, stderr] = await Promise.all([
|
|
79
|
+
mixedCmd.strings.stdout,
|
|
80
|
+
mixedCmd.strings.stderr,
|
|
81
|
+
]);
|
|
82
|
+
|
|
83
|
+
console.log('Stdout:', JSON.stringify(stdout.trim()));
|
|
84
|
+
console.log('Stderr:', JSON.stringify(stderr.trim()));
|
|
85
|
+
|
|
86
|
+
console.log('\\n✅ EXAMPLE 5: Backward compatibility');
|
|
87
|
+
console.log('─'.repeat(30));
|
|
88
|
+
|
|
89
|
+
// Traditional await syntax still works
|
|
90
|
+
const compatCmd = await $`echo "backward compatible"`;
|
|
91
|
+
console.log('Compatible result:', JSON.stringify(compatCmd.stdout.trim()));
|
|
92
|
+
|
|
93
|
+
console.log(`\\n${'='.repeat(50)}`);
|
|
94
|
+
console.log('🎉 All README examples completed!');
|
|
95
|
+
console.log('\\n📋 Key Features:');
|
|
96
|
+
console.log(' ✅ command.streams.stdin/stdout/stderr - Node.js streams');
|
|
97
|
+
console.log(' ✅ command.buffers.stdin/stdout/stderr - Buffer objects');
|
|
98
|
+
console.log(' ✅ command.strings.stdin/stdout/stderr - String data');
|
|
99
|
+
console.log(
|
|
100
|
+
' ✅ command.kill() - Process termination'
|
|
101
|
+
);
|
|
102
|
+
console.log(
|
|
103
|
+
' ✅ Backward compatible with await - Original syntax works'
|
|
104
|
+
);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
console.error('❌ Error:', error.message);
|
|
107
|
+
console.error(error.stack);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
readmeExamples();
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
# Command Stream Examples
|
|
2
|
+
|
|
3
|
+
This directory contains 160+ examples demonstrating various features of the command-stream library. Each example focuses on a specific concept or use case.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
The simplest examples to get started:
|
|
8
|
+
|
|
9
|
+
- `readme-example.mjs` - Basic usage from the main README
|
|
10
|
+
- `ping-streaming-simple.mjs` - Simple streaming example
|
|
11
|
+
- `syntax-basic-options.mjs` - Basic $({ options }) syntax
|
|
12
|
+
|
|
13
|
+
## Categories
|
|
14
|
+
|
|
15
|
+
### 🎛️ Options and Configuration
|
|
16
|
+
|
|
17
|
+
**$({ options }) Syntax:**
|
|
18
|
+
|
|
19
|
+
- `syntax-basic-options.mjs` - Basic options verification
|
|
20
|
+
- `syntax-custom-stdin.mjs` - Custom stdin using options
|
|
21
|
+
- `syntax-custom-environment.mjs` - Custom environment variables
|
|
22
|
+
- `syntax-custom-directory.mjs` - Custom working directory
|
|
23
|
+
- `syntax-combined-options.mjs` - Multiple options combined
|
|
24
|
+
- `syntax-reusable-configs.mjs` - Reusable configurations
|
|
25
|
+
- `syntax-mixed-usage.mjs` - Mix with regular $ usage
|
|
26
|
+
- `syntax-silent-operations.mjs` - Silent operations (no mirror)
|
|
27
|
+
- `syntax-stdin-option.mjs` - stdin option verification
|
|
28
|
+
- `syntax-command-chaining.mjs` - Command chaining verification
|
|
29
|
+
- `syntax-reusable-config.mjs` - Multiple uses of same config
|
|
30
|
+
|
|
31
|
+
**Capture/Mirror Options:**
|
|
32
|
+
|
|
33
|
+
- `capture-mirror-default.mjs` - Default behavior (both enabled)
|
|
34
|
+
- `capture-mirror-silent-processing.mjs` - capture: true, mirror: false
|
|
35
|
+
- `capture-mirror-show-only.mjs` - capture: false, mirror: true
|
|
36
|
+
- `capture-mirror-performance.mjs` - capture: false, mirror: false
|
|
37
|
+
- `capture-mirror-comparison.mjs` - Summary of all combinations
|
|
38
|
+
- `options-capture-false.mjs` - Using .start() with capture: false
|
|
39
|
+
- `options-mirror-false.mjs` - Using .start() with mirror: false
|
|
40
|
+
- `options-combined-settings.mjs` - Using both mirror and capture options
|
|
41
|
+
- `options-default-behavior.mjs` - Default behavior comparison
|
|
42
|
+
- `options-performance-mode.mjs` - Maximum performance mode
|
|
43
|
+
|
|
44
|
+
**Performance Optimization:**
|
|
45
|
+
|
|
46
|
+
- `options-performance-optimization.mjs` - Disable capture for speed
|
|
47
|
+
- `options-silent-execution.mjs` - Disable mirroring
|
|
48
|
+
- `options-maximum-performance.mjs` - No capture, no mirror
|
|
49
|
+
- `options-custom-input.mjs` - Custom input with options
|
|
50
|
+
|
|
51
|
+
**Method Usage:**
|
|
52
|
+
|
|
53
|
+
- `methods-start-basic.mjs` - Using .start() method
|
|
54
|
+
- `methods-run-basic.mjs` - Using .run() method (identical to .start())
|
|
55
|
+
- `methods-multiple-options.mjs` - Both methods support same options
|
|
56
|
+
- `options-run-alias.mjs` - Using .run() alias with options
|
|
57
|
+
- `options-run-alias-demo.mjs` - Using .run() alias demonstration
|
|
58
|
+
|
|
59
|
+
### 📡 Streaming Examples
|
|
60
|
+
|
|
61
|
+
**Basic Streaming:**
|
|
62
|
+
|
|
63
|
+
- `streaming-direct-command.mjs` - Direct command streaming
|
|
64
|
+
- `streaming-silent-capture.mjs` - Long-running with silent capture
|
|
65
|
+
- `streaming-progress-tracking.mjs` - Progress tracking with streaming
|
|
66
|
+
- `streaming-filtered-output.mjs` - Stream processing with filtering
|
|
67
|
+
- `streaming-reusable-configs.mjs` - Reusable streaming configurations
|
|
68
|
+
- `streaming-interactive-stdin.mjs` - Interactive streaming with custom stdin
|
|
69
|
+
|
|
70
|
+
**Pipeline Streaming:**
|
|
71
|
+
|
|
72
|
+
- `streaming-jq-pipeline.mjs` - jq pipeline streaming (critical test)
|
|
73
|
+
- `streaming-multistage-pipeline.mjs` - Multi-stage pipeline (cat | jq)
|
|
74
|
+
- `streaming-grep-pipeline.mjs` - grep pipeline streaming
|
|
75
|
+
- `streaming-virtual-pipeline.mjs` - Virtual command with pipeline
|
|
76
|
+
|
|
77
|
+
**Advanced Streaming:**
|
|
78
|
+
|
|
79
|
+
- `streaming-pipes-realtime-jq.mjs` - Real-time streaming through jq
|
|
80
|
+
- `streaming-pipes-multistage.mjs` - Multi-stage pipeline streaming
|
|
81
|
+
- `streaming-pipes-event-pattern.mjs` - EventEmitter pattern with pipes
|
|
82
|
+
- `streaming-behavior-test.mjs` - Comprehensive streaming behavior analysis
|
|
83
|
+
|
|
84
|
+
**Options-Based Streaming:**
|
|
85
|
+
|
|
86
|
+
- `options-streaming-silent.mjs` - Silent streaming with $({ mirror: false })
|
|
87
|
+
- `options-streaming-stdin.mjs` - Custom stdin streaming
|
|
88
|
+
- `options-streaming-capture.mjs` - Capture enabled with streaming
|
|
89
|
+
- `options-streaming-multiple.mjs` - Multiple configured instances
|
|
90
|
+
|
|
91
|
+
### 🏓 Ping Examples
|
|
92
|
+
|
|
93
|
+
**Basic Ping:**
|
|
94
|
+
|
|
95
|
+
- `ping-streaming-simple.mjs` - Minimal ping streaming example
|
|
96
|
+
- `ping-streaming.mjs` - Enhanced ping with timestamps and parsing
|
|
97
|
+
- `ping-streaming-timestamps.mjs` - Basic ping with timestamps
|
|
98
|
+
- `ping-streaming-filtered.mjs` - Filtering only ping replies
|
|
99
|
+
- `ping-streaming-statistics.mjs` - Counting responses with statistics
|
|
100
|
+
- `ping-streaming-silent.mjs` - Silent streaming with options
|
|
101
|
+
- `ping-streaming-interruptible.mjs` - CTRL+C handling with streams
|
|
102
|
+
|
|
103
|
+
### 🎨 ANSI Color Handling
|
|
104
|
+
|
|
105
|
+
**Basic Color Examples:**
|
|
106
|
+
|
|
107
|
+
- `colors-default-preserved.mjs` - Default behavior (ANSI preserved)
|
|
108
|
+
- `colors-strip-ansi.mjs` - Using AnsiUtils.stripAnsi()
|
|
109
|
+
- `colors-buffer-processing.mjs` - Using AnsiUtils.cleanForProcessing()
|
|
110
|
+
- `colors-per-command-config.mjs` - Per-command ANSI configuration
|
|
111
|
+
- `ansi-default-preserved.mjs` - Default ANSI preservation
|
|
112
|
+
- `ansi-strip-utils.mjs` - Using AnsiUtils to strip ANSI
|
|
113
|
+
- `ansi-global-config.mjs` - Global configuration to disable ANSI
|
|
114
|
+
- `ansi-reset-default.mjs` - Reset to default (preserve ANSI)
|
|
115
|
+
|
|
116
|
+
**Interactive Examples:**
|
|
117
|
+
|
|
118
|
+
- `interactive-top.mjs` - Interactive `top` command with full ANSI support
|
|
119
|
+
- `interactive-top-fixed.mjs` - Fixed version of interactive top
|
|
120
|
+
- `interactive-top-improved.mjs` - Improved interactive top
|
|
121
|
+
- `interactive-top-pty.mjs` - Interactive top with PTY
|
|
122
|
+
- `interactive-top-pty-logging.mjs` - PTY with logging
|
|
123
|
+
- `interactive-top-with-logging.mjs` - Interactive top with logging
|
|
124
|
+
- `example-top.mjs` - Simple `top` command example
|
|
125
|
+
- `example-ansi-ls.mjs` - ls command ANSI color handling
|
|
126
|
+
|
|
127
|
+
**jq Color Examples:**
|
|
128
|
+
|
|
129
|
+
- `jq-colors-streaming.mjs` - jq streaming with ANSI colors
|
|
130
|
+
- `test-jq-colors.mjs` - Comprehensive jq color testing
|
|
131
|
+
|
|
132
|
+
### ⚡ Event-Based Processing
|
|
133
|
+
|
|
134
|
+
**Basic Events:**
|
|
135
|
+
|
|
136
|
+
- `events-ping-basic.mjs` - Basic event-based ping
|
|
137
|
+
- `events-stdin-input.mjs` - Event-based with custom stdin
|
|
138
|
+
- `events-progress-tracking.mjs` - Long-running process with progress events
|
|
139
|
+
- `events-error-handling.mjs` - Error handling and recovery
|
|
140
|
+
- `events-concurrent-streams.mjs` - Multiple concurrent event streams
|
|
141
|
+
|
|
142
|
+
**Real-World Event Patterns:**
|
|
143
|
+
|
|
144
|
+
- `events-log-processing.mjs` - Real-time log processing
|
|
145
|
+
- `events-file-monitoring.mjs` - File monitoring simulation
|
|
146
|
+
- `events-build-process.mjs` - Build process simulation
|
|
147
|
+
- `events-interactive-simulation.mjs` - Interactive command simulation
|
|
148
|
+
- `events-network-monitoring.mjs` - Network monitoring with multiple hosts
|
|
149
|
+
|
|
150
|
+
### 🚦 CTRL+C Signal Handling
|
|
151
|
+
|
|
152
|
+
**Basic Signal Handling:**
|
|
153
|
+
|
|
154
|
+
- `ctrl-c-long-running-command.mjs` - Long-running command interruption
|
|
155
|
+
- `ctrl-c-sleep-command.mjs` - Sleep command with signal handling
|
|
156
|
+
- `ctrl-c-stdin-forwarding.mjs` - Command with stdin forwarding
|
|
157
|
+
- `ctrl-c-real-system-command.mjs` - Real system command CTRL+C
|
|
158
|
+
- `ctrl-c-virtual-command.mjs` - Virtual command CTRL+C
|
|
159
|
+
- `ctrl-c-concurrent-processes.mjs` - Multiple concurrent processes
|
|
160
|
+
|
|
161
|
+
### 🔧 Syntax Comparisons
|
|
162
|
+
|
|
163
|
+
**Feature Comparisons:**
|
|
164
|
+
|
|
165
|
+
- `syntax-basic-comparison.mjs` - Basic $ vs $({ options }) comparison
|
|
166
|
+
- `syntax-piping-comparison.mjs` - Command chaining comparison
|
|
167
|
+
- `syntax-multiple-listeners.mjs` - Multiple event listeners comparison
|
|
168
|
+
|
|
169
|
+
### 🧪 Testing and Debugging
|
|
170
|
+
|
|
171
|
+
**Core Functionality Tests:**
|
|
172
|
+
|
|
173
|
+
- `test-stream-cleanup.mjs` - Stream cleanup behavior
|
|
174
|
+
- `test-cleanup-simple.mjs` - Simplified cleanup test
|
|
175
|
+
- `test-debug.mjs` - Debug version with internal state
|
|
176
|
+
- `test-events.mjs` - Event handling tests
|
|
177
|
+
- `test-raw-streaming.mjs` - Raw streaming (no jq) tests
|
|
178
|
+
- `test-bun-streaming.mjs` - Bun-specific streaming tests
|
|
179
|
+
|
|
180
|
+
**Pipeline Tests:**
|
|
181
|
+
|
|
182
|
+
- `test-simple-pipe.mjs` - Simple pipeline tests
|
|
183
|
+
- `test-sh-pipeline.mjs` - Shell pipeline tests
|
|
184
|
+
- `test-direct-pipe-reading.mjs` - Direct pipe reading tests
|
|
185
|
+
- `test-no-parse-pipeline.mjs` - No parse pipeline tests
|
|
186
|
+
|
|
187
|
+
**Virtual Command Tests:**
|
|
188
|
+
|
|
189
|
+
- `test-virtual-streaming.mjs` - Virtual command streaming tests
|
|
190
|
+
- `test-real-commands.mjs` - Real command tests
|
|
191
|
+
- `test-real-shell.mjs` - Real shell command tests
|
|
192
|
+
|
|
193
|
+
**Advanced Tests:**
|
|
194
|
+
|
|
195
|
+
- `test-incremental-streaming.mjs` - Incremental streaming tests
|
|
196
|
+
- `test-multi-stream.mjs` - Multiple stream tests
|
|
197
|
+
- `test-final-streaming.mjs` - Final streaming tests
|
|
198
|
+
- `test-streaming-final.mjs` - Streaming final tests
|
|
199
|
+
- `test-multistage-debug.mjs` - Multi-stage debug tests
|
|
200
|
+
|
|
201
|
+
**CTRL+C Tests:**
|
|
202
|
+
|
|
203
|
+
- `test-ctrl-c.mjs` - Basic CTRL+C tests
|
|
204
|
+
- `test-ctrl-c-debug.mjs` - CTRL+C debug tests
|
|
205
|
+
- `test-ctrl-c-inherit.mjs` - CTRL+C inheritance tests
|
|
206
|
+
- `test-ctrl-c-sleep.mjs` - CTRL+C sleep tests
|
|
207
|
+
- `test-interrupt.mjs` - Interrupt tests
|
|
208
|
+
- `test-parent-continues.mjs` - Parent continuation tests
|
|
209
|
+
- `manual-ctrl-c-test.mjs` - Manual CTRL+C test
|
|
210
|
+
|
|
211
|
+
**PTY and Interactive Tests:**
|
|
212
|
+
|
|
213
|
+
- `test-pty.mjs` - PTY tests
|
|
214
|
+
- `test-pty-spawn.mjs` - PTY spawn tests
|
|
215
|
+
- `test-debug-pty.mjs` - Debug PTY tests
|
|
216
|
+
- `test-interactive.mjs` - Interactive tests
|
|
217
|
+
|
|
218
|
+
**jq and JSON Tests:**
|
|
219
|
+
|
|
220
|
+
- `test-jq-compact.mjs` - jq compact tests
|
|
221
|
+
- `test-jq-realtime.mjs` - jq realtime tests
|
|
222
|
+
- `test-direct-jq.mjs` - Direct jq tests
|
|
223
|
+
- `simple-jq-streaming.mjs` - Simple jq streaming tests
|
|
224
|
+
- `realtime-json-stream.mjs` - Realtime JSON streaming
|
|
225
|
+
|
|
226
|
+
**Node.js Compatibility:**
|
|
227
|
+
|
|
228
|
+
- `node-compat-data-events.mjs` - Node.js spawn with data events
|
|
229
|
+
- `node-compat-readable-event.mjs` - Using readable event
|
|
230
|
+
- `node-compat-small-buffer.mjs` - Reading with small buffer size
|
|
231
|
+
|
|
232
|
+
**Debug and Analysis:**
|
|
233
|
+
|
|
234
|
+
- `debug-already-started.mjs` - Already started behavior
|
|
235
|
+
- `debug-ansi-processing.mjs` - ANSI processing debug
|
|
236
|
+
- `debug-event-vs-result.mjs` - Event vs result debug
|
|
237
|
+
- `debug-exact-command.mjs` - Exact command debug
|
|
238
|
+
- `debug-option-merging.mjs` - Option merging debug
|
|
239
|
+
- `debug-pipeline.mjs` - Pipeline debug
|
|
240
|
+
- `debug-pipeline-issue.mjs` - Pipeline issue debug
|
|
241
|
+
- `debug-pipeline-method.mjs` - Pipeline method debug
|
|
242
|
+
- `debug-simple.mjs` - Simple debug
|
|
243
|
+
- `debug-streaming.mjs` - Streaming debug
|
|
244
|
+
- `debug-virtual-vs-real.mjs` - Virtual vs real command debug
|
|
245
|
+
|
|
246
|
+
**Stream Analysis:**
|
|
247
|
+
|
|
248
|
+
- `test-stream-readers.mjs` - Stream readers tests
|
|
249
|
+
- `test-debug-tee.mjs` - Debug tee tests
|
|
250
|
+
- `test-debug-new-options.mjs` - Debug new options tests
|
|
251
|
+
- `test-individual-spawn.mjs` - Individual spawn tests
|
|
252
|
+
- `test-verbose.mjs` - Verbose tests
|
|
253
|
+
- `test-verbose2.mjs` - Verbose tests v2
|
|
254
|
+
|
|
255
|
+
**Emulation and Demos:**
|
|
256
|
+
|
|
257
|
+
- `emulate-claude-stream.mjs` - Claude streaming emulator
|
|
258
|
+
- `emulated-streaming-direct.mjs` - Direct emulator execution
|
|
259
|
+
- `emulated-streaming-jq-pipe.mjs` - Emulator piped through jq
|
|
260
|
+
- `emulated-streaming-sh-pipe.mjs` - Using sh -c with pipe
|
|
261
|
+
- `simple-stream-demo.mjs` - Simple streaming demo
|
|
262
|
+
- `working-streaming-demo.mjs` - Working streaming demonstration
|
|
263
|
+
|
|
264
|
+
**which Command Tests:**
|
|
265
|
+
|
|
266
|
+
- `which-command-gh-test.mjs` - Testing which gh (GitHub issue #7)
|
|
267
|
+
- `which-command-system-comparison.mjs` - Comparing with system which
|
|
268
|
+
- `which-command-common-commands.mjs` - Testing with common commands
|
|
269
|
+
- `which-command-nonexistent.mjs` - Testing non-existent commands
|
|
270
|
+
|
|
271
|
+
**Cat Command Tests:**
|
|
272
|
+
|
|
273
|
+
- `test-cat-direct.mjs` - Direct cat tests
|
|
274
|
+
- `test-cat-pipe.mjs` - Cat pipe tests
|
|
275
|
+
|
|
276
|
+
## Key Features Demonstrated
|
|
277
|
+
|
|
278
|
+
### 🎛️ Options and Configuration
|
|
279
|
+
|
|
280
|
+
- ✅ **$({ options }) syntax** - Clean API for passing options
|
|
281
|
+
- ✅ **Capture control** - Enable/disable output capture with `capture: true/false`
|
|
282
|
+
- ✅ **Mirror control** - Enable/disable terminal output with `mirror: true/false`
|
|
283
|
+
- ✅ **Custom stdin** - Pass custom input with `stdin` option
|
|
284
|
+
- ✅ **Environment variables** - Set custom environment with `env` option
|
|
285
|
+
- ✅ **Working directory** - Change directory with `cwd` option
|
|
286
|
+
- ✅ **Method aliases** - Use `.run()` as alias for `.start()`
|
|
287
|
+
|
|
288
|
+
### 📡 Real-Time Streaming
|
|
289
|
+
|
|
290
|
+
- ✅ **Async iteration** - `for await (const chunk of command.stream())`
|
|
291
|
+
- ✅ **Event-based processing** - `.on('stdout')`, `.on('stderr')`, `.on('close')`
|
|
292
|
+
- ✅ **Pipeline streaming** - Real-time streaming through jq, grep, sed
|
|
293
|
+
- ✅ **Multi-stage pipelines** - Complex command chains with streaming
|
|
294
|
+
- ✅ **Progress tracking** - Real-time progress monitoring
|
|
295
|
+
|
|
296
|
+
### 🎨 ANSI Color Handling
|
|
297
|
+
|
|
298
|
+
- ✅ **ANSI colors preserved by default** (addresses GitHub issue #10)
|
|
299
|
+
- ✅ **No interference with interactive I/O** (addresses GitHub issue #11)
|
|
300
|
+
- ✅ **Easy data processing** with `AnsiUtils` export functions
|
|
301
|
+
- ✅ **Configurable behavior** for different use cases
|
|
302
|
+
- ✅ **Stream compatibility** with existing tools
|
|
303
|
+
|
|
304
|
+
### 🚦 Signal Handling
|
|
305
|
+
|
|
306
|
+
- ✅ **CTRL+C forwarding** - Proper SIGINT signal forwarding to child processes
|
|
307
|
+
- ✅ **Process cleanup** - Clean termination without hanging processes
|
|
308
|
+
- ✅ **Interactive commands** - Full stdin/stdout/stderr inheritance
|
|
309
|
+
- ✅ **Virtual command cancellation** - Proper cleanup of async generators
|
|
310
|
+
|
|
311
|
+
### 🔧 Stream Management
|
|
312
|
+
|
|
313
|
+
- ✅ **Proper cleanup** - Breaking from `for await` loops properly terminates processes
|
|
314
|
+
- ✅ **No resource leaks** - Virtual commands are properly closed
|
|
315
|
+
- ✅ **Clean exit** - No hanging processes after iteration stops
|
|
316
|
+
|
|
317
|
+
## Usage Examples
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
# Run a basic example
|
|
321
|
+
bun js/examples/ping-streaming-simple.mjs
|
|
322
|
+
|
|
323
|
+
# Test ANSI color handling
|
|
324
|
+
node js/examples/colors-default-preserved.mjs
|
|
325
|
+
|
|
326
|
+
# Try CTRL+C signal handling
|
|
327
|
+
node js/examples/ctrl-c-long-running-command.mjs
|
|
328
|
+
|
|
329
|
+
# Test streaming with options
|
|
330
|
+
node js/examples/options-streaming-silent.mjs
|
|
331
|
+
|
|
332
|
+
# Event-based processing
|
|
333
|
+
node js/examples/events-log-processing.mjs
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## File Naming Convention
|
|
337
|
+
|
|
338
|
+
Files are named using the pattern `{category}-{feature}-{variant}.mjs`:
|
|
339
|
+
|
|
340
|
+
- `ping-streaming-simple.mjs` - Simple ping streaming
|
|
341
|
+
- `options-capture-false.mjs` - Options with capture disabled
|
|
342
|
+
- `events-log-processing.mjs` - Event-based log processing
|
|
343
|
+
- `syntax-basic-options.mjs` - Basic syntax for options
|
|
344
|
+
|
|
345
|
+
This makes it easy to find related examples and understand what each file demonstrates at a glance.
|