Files
linux-odyssey/packages/game/src/condition/OutputMatcher.ts
T
2024-03-07 00:50:42 +08:00

14 lines
365 B
TypeScript

import { Command } from '../types.js'
import { Matcher } from './Matcher.js'
export class OutputMatcher implements Matcher {
private matcher: RegExp
constructor(pattern: string, args?: string) {
this.matcher = new RegExp(pattern, args)
}
match(command: Command): boolean {
return !!command.output && this.matcher.test(command.output.trim())
}
}