@approval-tests/approvals 7.5.12 → 7.5.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/lib/Logs/LogUtils.js +5 -3
  2. package/package.json +10 -4
  3. package/bin/index.ts +0 -108
  4. package/lib/AUtils.ts +0 -178
  5. package/lib/Approvals.ts +0 -321
  6. package/lib/Core/Namer.ts +0 -14
  7. package/lib/Core/Options.ts +0 -94
  8. package/lib/Core/Reporter.ts +0 -13
  9. package/lib/Core/Writer.ts +0 -5
  10. package/lib/FileApprover.ts +0 -116
  11. package/lib/FinalMessages.ts +0 -16
  12. package/lib/Logs/ApprovedFileLog.ts +0 -38
  13. package/lib/Logs/FailedFileLog.ts +0 -36
  14. package/lib/Logs/LogUtils.ts +0 -44
  15. package/lib/ManualNamer.ts +0 -12
  16. package/lib/Namer.ts +0 -28
  17. package/lib/Providers/BeforeEachVerifierBase.ts +0 -68
  18. package/lib/Providers/Jest/CombinationApprovals.ts +0 -161
  19. package/lib/Providers/Jest/JestApprovals.ts +0 -50
  20. package/lib/Providers/Jest/JestNamer.ts +0 -15
  21. package/lib/Providers/Jest/JestReporter.ts +0 -25
  22. package/lib/Providers/Jest/JestSetup.ts +0 -40
  23. package/lib/Providers/Mocha/MochaApprovals.ts +0 -74
  24. package/lib/Providers/Mocha/MochaNamer.ts +0 -84
  25. package/lib/Providers/OptionalFramework.ts +0 -11
  26. package/lib/Providers/Vitest/VitestApprovals.ts +0 -39
  27. package/lib/Providers/Vitest/VitestNamer.ts +0 -27
  28. package/lib/Providers/Vitest/VitestReporter.ts +0 -25
  29. package/lib/Reporting/DiffReporterAggregate.ts +0 -36
  30. package/lib/Reporting/GenericDiffReporterBase.ts +0 -154
  31. package/lib/Reporting/ReportByOpeningTheReceivedFile.ts +0 -22
  32. package/lib/Reporting/ReportLaunchingCircuitBreaker.ts +0 -40
  33. package/lib/Reporting/ReporterFactory.ts +0 -85
  34. package/lib/Reporting/Reporters/beyondcompareReporter.ts +0 -30
  35. package/lib/Reporting/Reporters/codiumReporter.ts +0 -26
  36. package/lib/Reporting/Reporters/copycommandReporter.ts +0 -46
  37. package/lib/Reporting/Reporters/diffmergeReporter.ts +0 -25
  38. package/lib/Reporting/Reporters/donothingReporter.ts +0 -13
  39. package/lib/Reporting/Reporters/gitdiffReporter.ts +0 -28
  40. package/lib/Reporting/Reporters/icdiffReporter.ts +0 -10
  41. package/lib/Reporting/Reporters/kdiff3Reporter.ts +0 -10
  42. package/lib/Reporting/Reporters/kompareReporter.ts +0 -10
  43. package/lib/Reporting/Reporters/meldReporter.ts +0 -10
  44. package/lib/Reporting/Reporters/multiReporter.ts +0 -55
  45. package/lib/Reporting/Reporters/nodediffReporter.ts +0 -61
  46. package/lib/Reporting/Reporters/opendiffReporter.ts +0 -10
  47. package/lib/Reporting/Reporters/p4mergeReporter.ts +0 -39
  48. package/lib/Reporting/Reporters/tortoisemergeReporter.ts +0 -25
  49. package/lib/Reporting/Reporters/vimdiffReporter.ts +0 -25
  50. package/lib/Reporting/Reporters/visualstudioReporter.ts +0 -48
  51. package/lib/Reporting/Reporters/vscodeReporter.ts +0 -26
  52. package/lib/Scrubbers/DateScrubber.ts +0 -83
  53. package/lib/Scrubbers/Scrubbers.ts +0 -106
  54. package/lib/StringWriter.ts +0 -73
  55. package/lib/Utilities/ConsoleUtils.ts +0 -15
  56. package/lib/Utilities/JestUtils.ts +0 -5
  57. package/lib/Utilities/Logger/LoggingInstance.ts +0 -247
  58. package/lib/Utilities/Logger/SimpleLogger.ts +0 -83
  59. package/lib/Utilities/Logger/SimpleLoggerApprovals.ts +0 -15
  60. package/lib/Utilities/Logger/StringWrapper.ts +0 -12
  61. package/lib/Utilities/Logger/Wrapper.ts +0 -27
  62. package/lib/Utilities/Printers.ts +0 -77
  63. package/lib/Utilities/StringUtils.ts +0 -8
  64. package/lib/Writers/BinaryWriter.ts +0 -42
  65. package/lib/config.ts +0 -95
  66. package/lib/osTools.ts +0 -11
  67. package/lib/postRunCleanup.ts +0 -63
@@ -1,30 +0,0 @@
1
- import { searchForExecutable } from "../../AUtils";
2
- import { platform } from "../../osTools";
3
- import shelljs from "shelljs";
4
- import { GenericDiffReporterBase } from "../GenericDiffReporterBase";
5
-
6
- export default class BeyondCompareReporter extends GenericDiffReporterBase {
7
- constructor() {
8
- super("BeyondCompare");
9
-
10
- let app: string = "";
11
- if (platform.isMac) {
12
- try {
13
- app = shelljs.ls(
14
- "/Applications/Beyond Compare.app/Contents/MacOS/bcomp",
15
- )[0];
16
- } catch (err) {
17
- console.error(err);
18
- }
19
- app = app || searchForExecutable("bcomp");
20
- } else if (platform.isWindows) {
21
- app =
22
- searchForExecutable("Beyond Compare 4", "BCompare.exe") ||
23
- searchForExecutable("Beyond Compare 3", "BCompare.exe");
24
- }
25
-
26
- app = app || searchForExecutable("bcomp");
27
-
28
- this.exePath = app;
29
- }
30
- }
@@ -1,26 +0,0 @@
1
- import { platform } from "../../osTools";
2
- import { createEmptyFileIfNotExists, searchForExecutable } from "../../AUtils";
3
- import { GenericDiffReporterBase } from "../GenericDiffReporterBase";
4
-
5
- export default class CodiumReporter extends GenericDiffReporterBase {
6
- constructor() {
7
- super("codium");
8
-
9
- if (platform.isWindows) {
10
- this.exePath = searchForExecutable("codium.cmd");
11
- } else {
12
- this.exePath = searchForExecutable("codium");
13
- }
14
- }
15
-
16
- report(approved, received, options) {
17
- createEmptyFileIfNotExists(approved);
18
-
19
- options.cmdArgs = ["-n", "--diff", received, approved];
20
- options.cmdOptionOverrides = {
21
- detached: true,
22
- };
23
-
24
- return super.report(approved, received, options);
25
- }
26
- }
@@ -1,46 +0,0 @@
1
- import { Reporter } from "../../Core/Reporter";
2
- import { execSync } from "node:child_process";
3
-
4
- export default class CopyCommandReporter implements Reporter {
5
- public name: string;
6
-
7
- constructor() {
8
- this.name = "CopyCommand";
9
- }
10
-
11
- canReportOn(): boolean {
12
- return true;
13
- }
14
-
15
- report(approvedFilePath, receivedFilePath): void {
16
- const programs = {
17
- win32: {
18
- clipboard: "clip",
19
- fileCopy: "copy",
20
- },
21
- linux: {
22
- clipboard: "xclip -selection clipboard",
23
- fileCopy: "copy",
24
- },
25
- darwin: {
26
- clipboard: "pbcopy",
27
- fileCopy: "cp",
28
- },
29
- };
30
-
31
- const selectedPrograms = programs[process.platform];
32
-
33
- // EX: "copy my-file.received.txt my-file.approved.txt"
34
- const copyFragment =
35
- "'" + receivedFilePath + "' '" + approvedFilePath + "'";
36
-
37
- if (selectedPrograms) {
38
- execSync(selectedPrograms.clipboard, {
39
- input: selectedPrograms.fileCopy + " " + copyFragment,
40
- });
41
- } else {
42
- // some sort of fallback copy command logged to the console
43
- console.log("cp " + copyFragment);
44
- }
45
- }
46
- }
@@ -1,25 +0,0 @@
1
- import * as shelljs from "shelljs";
2
- import { platform } from "../../osTools";
3
- import { searchForExecutable } from "../../AUtils";
4
- import { GenericDiffReporterBase } from "../GenericDiffReporterBase";
5
-
6
- class Reporter extends GenericDiffReporterBase {
7
- constructor() {
8
- super("DiffMerge");
9
-
10
- let app: string | null = null;
11
- if (platform.isMac) {
12
- try {
13
- app = shelljs.ls(
14
- "/Applications/DiffMerge.app/Contents/MacOS/DiffMerge",
15
- )[0];
16
- } catch (err) {
17
- console.error(err);
18
- }
19
- }
20
-
21
- this.exePath = app || searchForExecutable("DiffMerge");
22
- }
23
- }
24
-
25
- export = Reporter;
@@ -1,13 +0,0 @@
1
- import { Reporter } from "../../Core/Reporter";
2
-
3
- export default class DoNothingReporter implements Reporter {
4
- name: string = "DoNothing";
5
-
6
- canReportOn() {
7
- return true;
8
- }
9
-
10
- report() {
11
- // Do nothing
12
- }
13
- }
@@ -1,28 +0,0 @@
1
- import { createEmptyFileIfNotExists, searchForExecutable } from "../../AUtils";
2
- import { Config } from "../../config";
3
- import { GenericDiffReporterBase } from "../GenericDiffReporterBase";
4
-
5
- export default class GitDiffReporter extends GenericDiffReporterBase {
6
- constructor() {
7
- super("GitDiff");
8
-
9
- this.exePath = searchForExecutable("Git/cmd", "git");
10
- }
11
-
12
- report(approved: string, received: string, options?: Partial<Config>) {
13
- options = options || {};
14
-
15
- createEmptyFileIfNotExists(approved);
16
- console.log(this.exePath);
17
-
18
- options.cmdArgs = ["diff", "--no-index", "--", received, approved];
19
-
20
- // force gitdiff to run synchronously so our console output
21
- // stays in order of test execution.
22
- const newOptions = Object.assign({}, options, {
23
- blockUntilReporterExits: true,
24
- });
25
-
26
- return super.report(approved, received, newOptions);
27
- }
28
- }
@@ -1,10 +0,0 @@
1
- import { searchForExecutable } from "../../AUtils";
2
- import { GenericDiffReporterBase } from "../GenericDiffReporterBase";
3
-
4
- export default class IcDiffReporter extends GenericDiffReporterBase {
5
- constructor() {
6
- super("icdiff");
7
-
8
- this.exePath = searchForExecutable("", "icdiff");
9
- }
10
- }
@@ -1,10 +0,0 @@
1
- import { GenericDiffReporterBase } from "../GenericDiffReporterBase";
2
- import { searchForExecutable } from "../../AUtils";
3
-
4
- export default class Kdiff3Reporter extends GenericDiffReporterBase {
5
- constructor() {
6
- super("Kdiff3");
7
-
8
- this.exePath = searchForExecutable("kdiff3");
9
- }
10
- }
@@ -1,10 +0,0 @@
1
- import { searchForExecutable } from "../../AUtils";
2
- import { GenericDiffReporterBase } from "../GenericDiffReporterBase";
3
-
4
- export default class KompareReporter extends GenericDiffReporterBase {
5
- constructor() {
6
- super("Kompare");
7
-
8
- this.exePath = searchForExecutable("kompare");
9
- }
10
- }
@@ -1,10 +0,0 @@
1
- import { GenericDiffReporterBase } from "../GenericDiffReporterBase";
2
- import { searchForExecutable } from "../../AUtils";
3
-
4
- export default class MeldReporter extends GenericDiffReporterBase {
5
- constructor() {
6
- super("Meld");
7
-
8
- this.exePath = searchForExecutable("meld");
9
- }
10
- }
@@ -1,55 +0,0 @@
1
- import { Reporter } from "../../Core/Reporter";
2
- import { ReporterFactory } from "../ReporterFactory";
3
-
4
- export default class MultiReporter implements Reporter {
5
- private reporters: Reporter[];
6
- public name: string;
7
- constructor(reporters) {
8
- reporters = reporters || [];
9
- if (!Array.isArray(reporters)) {
10
- throw new Error("reporters arguments is not an array of reporters");
11
- }
12
-
13
- this.reporters = ReporterFactory.loadAllReporters(reporters);
14
-
15
- this.name =
16
- "Multi (" +
17
- this.reporters
18
- .map(function (r) {
19
- return r.name;
20
- })
21
- .join(", ") +
22
- ")";
23
- }
24
-
25
- canReportOn(fileName) {
26
- return this.reporters.every(function (reporter) {
27
- return reporter.canReportOn(fileName);
28
- });
29
- }
30
-
31
- report(approvedFilePath, receivedFilePath, options) {
32
- var errors: any[] = [];
33
- this.reporters.forEach(function (reporter) {
34
- try {
35
- reporter.report(approvedFilePath, receivedFilePath, options);
36
- } catch (err) {
37
- errors.push(err);
38
- }
39
- });
40
-
41
- if (errors.length === 1) {
42
- throw errors[0];
43
- } else if (1 < errors.length) {
44
- var errorMessage =
45
- "There were multiple errors:\n\n" +
46
- errors
47
- .map((err) => {
48
- return " " + err.toString();
49
- })
50
- .join("\n");
51
-
52
- throw new Error(errorMessage);
53
- }
54
- }
55
- }
@@ -1,61 +0,0 @@
1
- import fs from "fs";
2
-
3
- import jsdiff from "diff";
4
- import {
5
- assertFileExists,
6
- createEmptyFileIfNotExists,
7
- isBinaryFile,
8
- } from "../../AUtils";
9
- import { Reporter } from "../../Core/Reporter";
10
- import { grayText, greenText, redText } from "../../Utilities/ConsoleUtils";
11
-
12
- export default class NodeDiffReporter implements Reporter {
13
- public name: string;
14
-
15
- constructor() {
16
- this.name = "nodediff";
17
- }
18
-
19
- canReportOn(fileName) {
20
- assertFileExists(fileName);
21
-
22
- var isBinary = isBinaryFile(fileName);
23
- if (isBinary) {
24
- return false;
25
- }
26
-
27
- return true;
28
- }
29
-
30
- report(approved, received, _options): void {
31
- createEmptyFileIfNotExists(approved);
32
-
33
- var approvedText = fs.readFileSync(approved).toString();
34
- var receivedText = fs.readFileSync(received).toString();
35
-
36
- console.log(`*******************************************`);
37
- console.log(`* Showing diff for ${approved} vs ${received}\n`);
38
-
39
- var diff = jsdiff.diffChars(approvedText, receivedText);
40
-
41
- diff.forEach(function (part) {
42
- // green for additions, red for deletions
43
- // grey for common parts
44
- let text = "";
45
- if (part.added) {
46
- text = greenText(part.value);
47
- } else {
48
- if (part.removed) {
49
- text = redText(part.value);
50
- } else {
51
- text = grayText(part.value);
52
- }
53
- }
54
-
55
- process.stdout.write(text);
56
- });
57
-
58
- console.log(`\n* End of diff for ${approved} vs ${received}`);
59
- console.log(`*******************************************\n\n`);
60
- }
61
- }
@@ -1,10 +0,0 @@
1
- import { searchForExecutable } from "../../AUtils";
2
- import { GenericDiffReporterBase } from "../GenericDiffReporterBase";
3
-
4
- export default class OpenDiffReporter extends GenericDiffReporterBase {
5
- constructor() {
6
- super("opendiff");
7
-
8
- this.exePath = searchForExecutable("", "opendiff");
9
- }
10
- }
@@ -1,39 +0,0 @@
1
- import fs from "fs";
2
- import shelljs from "shelljs";
3
- import { GenericDiffReporterBase } from "../GenericDiffReporterBase";
4
- import { platform } from "../../osTools";
5
- import { searchForExecutable } from "../../AUtils";
6
-
7
- export default class P4MergeReporter extends GenericDiffReporterBase {
8
- constructor() {
9
- super("P4Merge");
10
-
11
- let app = null;
12
- if (platform.isMac) {
13
- try {
14
- app = shelljs.ls(
15
- "/Applications/p4merge.app/Contents/Resources/launchp4merge",
16
- )[0];
17
- } catch (err) {
18
- console.error(err);
19
- }
20
-
21
- try {
22
- // `shelljs.find` will `process.exit` on error - so test the folder exists first
23
- if (fs.existsSync("/opt/homebrew-cask/Caskroom/p4merge")) {
24
- app =
25
- app ||
26
- shelljs
27
- .find("/opt/homebrew-cask/Caskroom/p4merge")
28
- .filter(function (item) {
29
- return item.indexOf("launchp4merge") >= 0;
30
- })[0];
31
- }
32
- } catch (err) {
33
- //console.error(err);
34
- }
35
- }
36
-
37
- this.exePath = app || searchForExecutable("Perforce", "p4merge.exe");
38
- }
39
- }
@@ -1,25 +0,0 @@
1
- import { searchForExecutable } from "../../AUtils";
2
- import { GenericDiffReporterBase } from "../GenericDiffReporterBase";
3
-
4
- export default class TortoiseMergeReporter extends GenericDiffReporterBase {
5
- constructor() {
6
- super("TortoiseMerge");
7
-
8
- var rootPaths = ["TortoiseGit/bin", "TortoiseSVN/bin"];
9
- var exeNames = ["TortoiseGitMerge.exe", "TortoiseMerge.exe"];
10
- let path: string = "";
11
-
12
- for (var i = 0; i < rootPaths.length; i++) {
13
- for (var j = 0; j < exeNames.length; j++) {
14
- path = searchForExecutable(rootPaths[i], exeNames[j]);
15
- if (path) {
16
- break;
17
- }
18
- }
19
- if (path) {
20
- break;
21
- }
22
- }
23
- this.exePath = path;
24
- }
25
- }
@@ -1,25 +0,0 @@
1
- import { GenericDiffReporterBase } from "../GenericDiffReporterBase";
2
- import { searchForExecutable } from "../../AUtils";
3
-
4
- export default class Reporter extends GenericDiffReporterBase {
5
- constructor() {
6
- super("VimDiff");
7
-
8
- // options.cmdOptions = {
9
- // stdio: "inherit",
10
- // };
11
-
12
- this.exePath = searchForExecutable("vim");
13
- this.setCommandArgs = (approved, received) => {
14
- return ["-d", received, approved];
15
- };
16
- this.modifyCommandOptions = (cmdOptions) => {
17
- if (!cmdOptions) {
18
- cmdOptions = {};
19
- }
20
-
21
- cmdOptions.stdio = "inherit";
22
- return cmdOptions;
23
- };
24
- }
25
- }
@@ -1,48 +0,0 @@
1
- import { GenericDiffReporterBase } from "../GenericDiffReporterBase";
2
- import { createEmptyFileIfNotExists } from "../../AUtils";
3
- import { platform } from "../../osTools";
4
-
5
- export default class VisualStudioReporter extends GenericDiffReporterBase {
6
- constructor() {
7
- super("VisualStudio");
8
-
9
- if (platform.isWindows) {
10
- var edge = require("edge");
11
-
12
- // Use edge to execute some .net and go find the installed version of visual studio.
13
- var getVisualStudioPath = edge.func(function () {
14
- /*
15
- async (input) => {
16
- // pulled this from https://github.com/approvals/ApprovalTests.Net/blob/master/ApprovalTests/Reporters/VisualStudioReporter.cs
17
- return (string)Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\devenv.exe", "", @"Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe");
18
- }
19
- */
20
- });
21
- this.exePath = getVisualStudioPath(null, true);
22
- }
23
- }
24
-
25
- canReportOn(fileName) {
26
- if (platform.isWindows) {
27
- return super.canReportOn(fileName);
28
- }
29
-
30
- return false;
31
- }
32
-
33
- report(approved, received) {
34
- createEmptyFileIfNotExists(approved);
35
-
36
- const ps = this.spawn(this.exePath, ["/diff", received, approved], {
37
- detached: true,
38
- });
39
-
40
- ps.stdout.on("data", function (data) {
41
- console.log("reporter stdout: " + data);
42
- });
43
-
44
- ps.stderr.on("data", function (data) {
45
- console.log("reporter stderr: " + data);
46
- });
47
- }
48
- }
@@ -1,26 +0,0 @@
1
- import { platform } from "../../osTools";
2
- import { createEmptyFileIfNotExists, searchForExecutable } from "../../AUtils";
3
- import { GenericDiffReporterBase } from "../GenericDiffReporterBase";
4
-
5
- export default class VSCodeReporter extends GenericDiffReporterBase {
6
- constructor() {
7
- super("vscode");
8
-
9
- if (platform.isWindows) {
10
- this.exePath = searchForExecutable("code.cmd");
11
- } else {
12
- this.exePath = searchForExecutable("code");
13
- }
14
- }
15
-
16
- report(approved, received, options) {
17
- createEmptyFileIfNotExists(approved);
18
-
19
- options.cmdArgs = ["-n", "--diff", received, approved];
20
- options.cmdOptionOverrides = {
21
- detached: true,
22
- };
23
-
24
- return super.report(approved, received, options);
25
- }
26
- }
@@ -1,83 +0,0 @@
1
- import { Scrubbers } from "./Scrubbers";
2
- import type { Scrubber } from "./Scrubbers";
3
-
4
- class DateFormat {
5
- public regex: RegExp;
6
- public examples: string[];
7
-
8
- constructor(regex: RegExp, examples: string[]) {
9
- this.regex = regex;
10
- this.examples = examples;
11
- }
12
- }
13
-
14
- function __(regExp: RegExp, strings: string[]): DateFormat {
15
- return new DateFormat(regExp, strings);
16
- }
17
-
18
- export class DateScrubber {
19
- static getSupportedFormats(): DateFormat[] {
20
- return [
21
- __(/[a-zA-Z]{3} [a-zA-Z]{3} \d{2} \d{2}:\d{2}:\d{2}/g, [
22
- "Tue May 13 16:30:00",
23
- ]),
24
- __(
25
- /[a-zA-Z]{3} [a-zA-Z]{3} \d{2} \d{2}:\d{2}:\d{2} [a-zA-Z]{3,4} \d{4}/g,
26
- ["Wed Nov 17 22:28:33 EET 2021"],
27
- ),
28
- __(/[a-zA-Z]{3} [a-zA-Z]{3} \d{2} \d{4} \d{2}:\d{2}:\d{2}.\d{3}/g, [
29
- "Tue May 13 2014 23:30:00.789",
30
- ]),
31
- __(/[a-zA-Z]{3} [a-zA-Z]{3} \d{2} \d{2}:\d{2}:\d{2} -\d{4} \d{4}/g, [
32
- "Tue May 13 16:30:00 -0800 2014",
33
- ]),
34
- __(/\d{2} [a-zA-Z]{3} \d{4} \d{2}:\d{2}:\d{2},\d{3}/g, [
35
- "13 May 2014 23:50:49,999",
36
- ]),
37
- __(
38
- /[a-zA-Z]{3} \d{2}, \d{4} \d{2}:\d{2}:\d{2} [a-zA-Z]{2} [a-zA-Z]{3}/g,
39
- ["May 13, 2014 11:30:00 PM PST"],
40
- ),
41
- __(/\d{2}:\d{2}:\d{2}/g, ["23:30:00"]),
42
- __(/\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}.\d{2}\d/g, [
43
- "2014/05/13 16:30:59.786",
44
- ]),
45
- __(/\d{4}-\d{1,2}-\d{1,2}T\d{1,2}:\d{2}Z/g, [
46
- "2020-9-10T08:07Z",
47
- "2020-09-9T08:07Z",
48
- "2020-09-10T8:07Z",
49
- "2020-09-10T08:07Z",
50
- ]),
51
- __(/\d{4}-\d{1,2}-\d{1,2}T\d{1,2}:\d{2}:\d{2}Z/g, [
52
- "2020-09-10T08:07:89Z",
53
- ]),
54
- __(/\d{4}-\d{1,2}-\d{1,2}T\d{1,2}:\d{2}\:\d{2}\.\d{3}Z/g, [
55
- "2020-09-10T01:23:45.678Z",
56
- ]),
57
- __(/\d{8}T\d{6}Z/g, ["20210505T091112Z"]),
58
- __(
59
- /[a-zA-Z]{3}, \d{2} [a-zA-Z]{3} \d{4} \d{2}:\d{2}:\d{2} [a-zA-Z]{3}/g,
60
- ["Sun, 06 Nov 2022 11:23:20 GMT"],
61
- ),
62
- ];
63
- }
64
-
65
- static getScrubberFor(example: string): Scrubber {
66
- let supported = "";
67
- for (let format of DateScrubber.getSupportedFormats()) {
68
- const scrubber = this.create(format.regex);
69
- const scrubbed = scrubber(example);
70
- if (scrubbed === "<date_1>") {
71
- return scrubber;
72
- }
73
- supported += ` ${format.examples[0]} | ${format.regex} \n`;
74
- }
75
- throw new Error(
76
- `No match found for '${example}'.\n Feel free to add your date at https://github.com/approvals/Approvals.NodeJS/issues/139 \n Current supported formats are: \n${supported}`,
77
- );
78
- }
79
-
80
- public static create(regex: RegExp): Scrubber {
81
- return Scrubbers.createReqexScrubber(regex, (t) => `<date_${t}>`);
82
- }
83
- }