diff --git a/tracers.ts/src/context/tracer-context.ts b/tracers.ts/src/context/tracer-context.ts index 1a7c713..e1b8c5d 100644 --- a/tracers.ts/src/context/tracer-context.ts +++ b/tracers.ts/src/context/tracer-context.ts @@ -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); diff --git a/tracers.ts/src/index.ts b/tracers.ts/src/index.ts index a6de801..77788ee 100644 --- a/tracers.ts/src/index.ts +++ b/tracers.ts/src/index.ts @@ -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();