Skip to content

Commit cff9226

Browse files
committed
fix: move regex out of class as constant
1 parent 2013cfb commit cff9226

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/metric/deprecated-images/deprecated-images.collector.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
// @ts-expect-error it's a js library
21
import cfLogs from 'cf-logs';
32

43
// eslint-disable-next-line import/no-unresolved
54
import { DeprecatedImageDto } from './deprecated-image.dto';
65

76
const logger = cfLogs.Logger('codefresh:containerLogger');
87

8+
// eslint-disable-next-line no-control-regex
9+
const DEPRECATED_IMAGE_REGEX = /^\u001b\[31m\u001b\[1m\[DEPRECATION NOTICE].+?Suggest the author of (?<image>.+?) to/;
10+
911
class DeprecatedImagesCollector {
1012

1113
private list: DeprecatedImageDto[] = [];
@@ -35,9 +37,7 @@ class DeprecatedImagesCollector {
3537
}
3638

3739
private _parseImageName(logText: string) {
38-
// eslint-disable-next-line no-control-regex
39-
const regex = /^\u001b\[31m\u001b\[1m\[DEPRECATION NOTICE].+?Suggest the author of (?<image>.+?) to/;
40-
const match = logText.match(regex);
40+
const match = logText.match(DEPRECATED_IMAGE_REGEX);
4141
return match?.groups?.image ?? null;
4242
}
4343
}

0 commit comments

Comments
 (0)