refactor(tracer-context): 移除自动输出指令序列的逻辑

移除 process.on('exit') 中的自动输出逻辑,改为通过 dump 方法手动获取指令序列。
This commit is contained in:
2026-02-13 20:57:27 +08:00
parent 305a9c7dc3
commit 9d5a46129e

View File

@@ -3,22 +3,27 @@ import type { TracerCommand } from '../types';
const createTracerContext = () => { const createTracerContext = () => {
const commands: TracerCommand[] = []; const commands: TracerCommand[] = [];
if (typeof process !== 'undefined' && typeof process.on === 'function') { // if (typeof process !== 'undefined' && typeof process.on === 'function') {
process.on('exit', () => { // process.on('exit', () => {
if (commands.length > 0) { // if (commands.length > 0) {
console.log(commands); // console.log(commands);
} // }
}); // });
} // }
const getTracerContext = () => { const getTracerContext = () => {
const command = (command: TracerCommand) => { const command = (command: TracerCommand) => {
commands.push(command); commands.push(command);
}; };
// TODO: 输出指令序列
const dump = () => {
return commands;
};
return { return {
commands,
command, command,
dump,
}; };
}; };