feat: 在退出前输出指令序列
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user