feat: 在退出前输出指令序列
This commit is contained in:
@@ -3,6 +3,14 @@ import type { TracerCommand } from '../types';
|
|||||||
const createTracerContext = () => {
|
const createTracerContext = () => {
|
||||||
const commands: TracerCommand[] = [];
|
const commands: TracerCommand[] = [];
|
||||||
|
|
||||||
|
if (typeof process !== 'undefined' && typeof process.on === 'function') {
|
||||||
|
process.on('exit', () => {
|
||||||
|
if (commands.length > 0) {
|
||||||
|
console.log(commands);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const getTracerContext = () => {
|
const getTracerContext = () => {
|
||||||
const command = (command: TracerCommand) => {
|
const command = (command: TracerCommand) => {
|
||||||
commands.push(command);
|
commands.push(command);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { getTracerContext } from './context';
|
|
||||||
import {
|
import {
|
||||||
createArrayTracer,
|
createArrayTracer,
|
||||||
createControlTracer,
|
createControlTracer,
|
||||||
@@ -15,6 +14,6 @@ const arrayTracer = createArrayTracer({
|
|||||||
|
|
||||||
arrayTracer.patch(0, 100);
|
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