refactor(tracer-context): 移除自动输出指令序列的逻辑
移除 process.on('exit') 中的自动输出逻辑,改为通过 dump 方法手动获取指令序列。
This commit is contained in:
@@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user