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 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,
};
};