mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
19 lines
424 B
TypeScript
19 lines
424 B
TypeScript
import { Matcher } from './Matcher.js'
|
|
import { Command } from '../types.js'
|
|
|
|
export class ErrorMatcher implements Matcher {
|
|
private matcher?: RegExp
|
|
constructor(errorPattern?: string) {
|
|
if (errorPattern) {
|
|
this.matcher = new RegExp(errorPattern)
|
|
}
|
|
}
|
|
|
|
match(command: Command): boolean {
|
|
if (!this.matcher) {
|
|
return !command.error
|
|
}
|
|
return this.matcher.test(command.error || '')
|
|
}
|
|
}
|