From 9d5a46129e843f44ec8c5cef24df8307af690202 Mon Sep 17 00:00:00 2001 From: skycurtain Date: Fri, 13 Feb 2026 20:57:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor(tracer-context):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=BE=93=E5=87=BA=E6=8C=87=E4=BB=A4=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除 process.on('exit') 中的自动输出逻辑,改为通过 dump 方法手动获取指令序列。 --- tracers.ts/src/context/tracer-context.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tracers.ts/src/context/tracer-context.ts b/tracers.ts/src/context/tracer-context.ts index e1b8c5d..adef36a 100644 --- a/tracers.ts/src/context/tracer-context.ts +++ b/tracers.ts/src/context/tracer-context.ts @@ -3,22 +3,27 @@ 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); - } - }); - } + // 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); }; + // TODO: 输出指令序列 + const dump = () => { + return commands; + }; + return { - commands, command, + dump, }; };