From 7b1c87f2a4e918e70017cb3ff211d41089dc1a69 Mon Sep 17 00:00:00 2001 From: skycurtain Date: Fri, 6 Feb 2026 01:56:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=A8=E9=80=80=E5=87=BA=E5=89=8D?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E6=8C=87=E4=BB=A4=E5=BA=8F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tracers.ts/src/context/tracer-context.ts | 8 ++++++++ tracers.ts/src/index.ts | 5 ++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tracers.ts/src/context/tracer-context.ts b/tracers.ts/src/context/tracer-context.ts index 1a7c713..e1b8c5d 100644 --- a/tracers.ts/src/context/tracer-context.ts +++ b/tracers.ts/src/context/tracer-context.ts @@ -3,6 +3,14 @@ import type { TracerCommand } from '../types'; const createTracerContext = () => { const commands: TracerCommand[] = []; + if (typeof process !== 'undefined' && typeof process.on === 'function') { + process.on('exit', () => { + if (commands.length > 0) { + console.log(commands); + } + }); + } + const getTracerContext = () => { const command = (command: TracerCommand) => { commands.push(command); diff --git a/tracers.ts/src/index.ts b/tracers.ts/src/index.ts index a6de801..77788ee 100644 --- a/tracers.ts/src/index.ts +++ b/tracers.ts/src/index.ts @@ -1,4 +1,3 @@ -import { getTracerContext } from './context'; import { createArrayTracer, createControlTracer, @@ -15,6 +14,6 @@ const arrayTracer = createArrayTracer({ arrayTracer.patch(0, 100); -controlTracer.step(); +logTracer.log(`patch array[0] to 100`); -console.log(getTracerContext().commands); +controlTracer.step();