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