import { EventEmitter } from "events" ; import { promises as fs } from "fs" ; import * as path from "path" ; import * as tr from "text-runner-core" ; export class VersionCommand implements tr . commands . Command { emitter : EventEmitter ; constructor ( ) { this . emitter = new EventEmitter ( ) ; } emit ( name , payload ) { this . emitter . emit ( name , payload ) ; } async execute ( ) { const fileContent = await fs . readFile ( path . join ( __dirname , "../../package.json" ) , "utf-8" ) ; const pkg = JSON . parse ( fileContent ) ; this . emit ( "output" , `TextRunner v${ pkg . version }` ) ; } on ( name , handler ) { this . emitter . on ( name , handler ) ; return this ; } }