@approval-tests/approvals 7.6.2 → 7.6.3

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.
package/bin/index.js CHANGED
@@ -1,38 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
3
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
4
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
5
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -53,7 +20,7 @@ const marked_1 = require("marked");
53
20
  const marked_terminal_renderer_1 = require("marked-terminal-renderer");
54
21
  const minimist_1 = __importDefault(require("minimist"));
55
22
  const Approvals_1 = require("../lib/Approvals");
56
- const autils = __importStar(require("../lib/AUtils"));
23
+ const AUtils_1 = require("../lib/AUtils");
57
24
  const ConsoleUtils_1 = require("../lib/Utilities/ConsoleUtils");
58
25
  const verbose = process.argv.includes("--verbose");
59
26
  const printHelp = process.argv.includes("--help");
@@ -121,8 +88,7 @@ function main() {
121
88
  console.log("approval opts: ", opts);
122
89
  }
123
90
  opts.forceApproveAll =
124
- autils.hasCommandLineArgument("--forceapproveall") ||
125
- autils.hasCommandLineArgument("-f");
91
+ (0, AUtils_1.hasCommandLineArgument)("--forceapproveall") || (0, AUtils_1.hasCommandLineArgument)("-f");
126
92
  process.stdin.pipe(event_stream_1.default.mapSync((data) => {
127
93
  const dataToVerify = data.toString();
128
94
  (0, Approvals_1.configure)(opts);
package/lib/AUtils.js CHANGED
@@ -1,58 +1,28 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
35
5
  Object.defineProperty(exports, "__esModule", { value: true });
36
6
  exports.stringifyKeysInOrder = exports.fixFilePathSlashes = exports.searchForExecutable = exports.findProgramOnPath = exports.isBinaryFile = exports.hasCommandLineArgument = exports.assertFileExists = exports.createEmptyFileIfNotExists = void 0;
37
- const fs = __importStar(require("fs"));
38
- const path = __importStar(require("path"));
39
- const shell = __importStar(require("shelljs"));
40
- const osTools = __importStar(require("./osTools"));
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const shelljs_1 = __importDefault(require("shelljs"));
10
+ const osTools_1 = require("./osTools");
41
11
  const _cachedProgramLookups = {};
42
12
  const createEmptyFileIfNotExists = (file) => {
43
- if (!fs.existsSync(file)) {
44
- const ext = (path.extname(file) || "").toLowerCase();
13
+ if (!fs_1.default.existsSync(file)) {
14
+ const ext = (path_1.default.extname(file) || "").toLowerCase();
45
15
  if (ext === ".png") {
46
- fs.writeFileSync(file, fs.readFileSync(path.join(__dirname, "DummyApprovedFiles", "UnapprovedImage.png")));
16
+ fs_1.default.writeFileSync(file, fs_1.default.readFileSync(path_1.default.join(__dirname, "DummyApprovedFiles", "UnapprovedImage.png")));
47
17
  }
48
18
  else {
49
- fs.writeFileSync(file, "");
19
+ fs_1.default.writeFileSync(file, "");
50
20
  }
51
21
  }
52
22
  };
53
23
  exports.createEmptyFileIfNotExists = createEmptyFileIfNotExists;
54
24
  const assertFileExists = (file) => {
55
- if (!fs.existsSync(file)) {
25
+ if (!fs_1.default.existsSync(file)) {
56
26
  throw new Error("File not found: " + file);
57
27
  }
58
28
  };
@@ -84,12 +54,14 @@ const findProgramOnPath = (programName) => {
84
54
  if (_cachedProgramLookups.hasOwnProperty(programName)) {
85
55
  return _cachedProgramLookups[programName];
86
56
  }
87
- const output = shell.exec(`${osTools.findProgramPathCommand} ${programName}`, { silent: true });
57
+ const output = shelljs_1.default.exec(`${osTools_1.findProgramPathCommand} ${programName}`, {
58
+ silent: true,
59
+ });
88
60
  let result = null;
89
61
  if (output.stdout) {
90
62
  const file = output.stdout.split("\n")[0].trim();
91
63
  const fixedFile = fixFilePathSlashes(file);
92
- if (fs.existsSync(fixedFile)) {
64
+ if (fs_1.default.existsSync(fixedFile)) {
93
65
  result = fixedFile;
94
66
  }
95
67
  }
@@ -113,7 +85,7 @@ const searchForExecutable = (folderInProgramInFiles, fileName) => {
113
85
  return programOnPath;
114
86
  }
115
87
  const lookInProgramFiles = (fileName_) => {
116
- if (osTools.platform.isWindows) {
88
+ if (osTools_1.platform.isWindows) {
117
89
  let tryVar = findInPath("C:/Program Files", folderInProgramInFiles || "", fileName_);
118
90
  if (tryVar) {
119
91
  return tryVar;
@@ -126,9 +98,9 @@ const searchForExecutable = (folderInProgramInFiles, fileName) => {
126
98
  return null;
127
99
  };
128
100
  const findInPath = (root, dir, file) => {
129
- const fullPath = path.join(root, dir, file);
101
+ const fullPath = path_1.default.join(root, dir, file);
130
102
  const fixedFullPath = fixFilePathSlashes(fullPath);
131
- if (fs.existsSync(fixedFullPath)) {
103
+ if (fs_1.default.existsSync(fixedFullPath)) {
132
104
  return fixedFullPath;
133
105
  }
134
106
  return null;
@@ -2,7 +2,7 @@
2
2
  * Approvals module.
3
3
  * @module approvals
4
4
  */
5
- import * as cfg from "./config";
5
+ import { Config } from "./config";
6
6
  import { Namer } from "./Core/Namer";
7
7
  import { Writer } from "./Core/Writer";
8
8
  import { ReporterLoader } from "./Reporting/ReporterFactory";
@@ -22,13 +22,13 @@ export { Scrubbers as scrubbers };
22
22
  *
23
23
  * @param {*} overrideOptions
24
24
  */
25
- export declare function configure(overrideOptions: cfg.Config): typeof module.exports;
25
+ export declare function configure(overrideOptions: Config): typeof module.exports;
26
26
  /**
27
27
  * Allows the creation of an approvals configuration object using any passed in options to override the defaults.
28
28
  * @param {Object} overrideOptions
29
29
  * @returns {Object} approvals config object with any options overridden.
30
30
  */
31
- export declare function getConfig(overrideOptions?: cfg.Config): cfg.Config;
31
+ export declare function getConfig(overrideOptions?: Config): Config;
32
32
  /**
33
33
  * Configure approvals to hook into Mocha tests.
34
34
  * @param {*} optionalBaseDir - An optional folder to save approval files to.
@@ -105,4 +105,4 @@ export declare function verifyAsJSONAndScrub(dirName: string, testName: string,
105
105
  * @param {Function} [reporterFactory]
106
106
  * @param {Object} [optionsOverride]
107
107
  */
108
- export declare function verifyWithControl(namer: Namer, writer: Writer, reporterFactory?: ReporterLoader | null, optionsOverride?: Partial<cfg.Config>): void;
108
+ export declare function verifyWithControl(namer: Namer, writer: Writer, reporterFactory?: ReporterLoader | null, optionsOverride?: Partial<Config>): void;
package/lib/Approvals.js CHANGED
@@ -3,39 +3,6 @@
3
3
  * Approvals module.
4
4
  * @module approvals
5
5
  */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- var desc = Object.getOwnPropertyDescriptor(m, k);
9
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
- desc = { enumerable: true, get: function() { return m[k]; } };
11
- }
12
- Object.defineProperty(o, k2, desc);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
- Object.defineProperty(o, "default", { enumerable: true, value: v });
19
- }) : function(o, v) {
20
- o["default"] = v;
21
- });
22
- var __importStar = (this && this.__importStar) || (function () {
23
- var ownKeys = function(o) {
24
- ownKeys = Object.getOwnPropertyNames || function (o) {
25
- var ar = [];
26
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
- return ar;
28
- };
29
- return ownKeys(o);
30
- };
31
- return function (mod) {
32
- if (mod && mod.__esModule) return mod;
33
- var result = {};
34
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
- __setModuleDefault(result, mod);
36
- return result;
37
- };
38
- })();
39
6
  var __importDefault = (this && this.__importDefault) || function (mod) {
40
7
  return (mod && mod.__esModule) ? mod : { "default": mod };
41
8
  };
@@ -52,7 +19,7 @@ const path_1 = __importDefault(require("path"));
52
19
  const url_1 = require("url");
53
20
  const callsite_1 = __importDefault(require("callsite"));
54
21
  const AUtils_1 = require("./AUtils");
55
- const cfg = __importStar(require("./config"));
22
+ const config_1 = require("./config");
56
23
  const FileApprover_1 = require("./FileApprover");
57
24
  const FinalMessages_1 = require("./FinalMessages");
58
25
  const ManualNamer_1 = require("./ManualNamer");
@@ -83,7 +50,7 @@ process.on("approvalFileApproved", function (fileName) {
83
50
  }
84
51
  });
85
52
  process.on("exit", function () {
86
- const options = cfg.currentConfig();
53
+ const options = (0, config_1.currentConfig)();
87
54
  (0, postRunCleanup_1.postRunCleanup)(options, approvedFilesSeenDuringTests);
88
55
  const finalMessages = FinalMessages_1.FinalMessages.getMessages();
89
56
  if (finalMessages.length) {
@@ -107,7 +74,7 @@ process.on("exit", function () {
107
74
  * @param {*} overrideOptions
108
75
  */
109
76
  function configure(overrideOptions) {
110
- cfg.configure(overrideOptions);
77
+ (0, config_1.configure)(overrideOptions);
111
78
  return module.exports;
112
79
  }
113
80
  /**
@@ -116,7 +83,7 @@ function configure(overrideOptions) {
116
83
  * @returns {Object} approvals config object with any options overridden.
117
84
  */
118
85
  function getConfig(overrideOptions) {
119
- return cfg.getConfig(overrideOptions);
86
+ return (0, config_1.getConfig)(overrideOptions);
120
87
  }
121
88
  /**
122
89
  * Configure approvals to hook into Mocha tests.
@@ -185,7 +152,7 @@ function verifyAndScrub(dirName, testName, data, scrubber, optionsOverride) {
185
152
  if (Array.isArray(optionsOverride)) {
186
153
  optionsOverride = convertDeprecatedReportersArray(optionsOverride);
187
154
  }
188
- const newOptions = cfg.getConfig(optionsOverride);
155
+ const newOptions = (0, config_1.getConfig)(optionsOverride);
189
156
  const namer = new ManualNamer_1.ManualNamer(dirName, testName);
190
157
  let writer;
191
158
  if (data instanceof Buffer) {
@@ -275,7 +242,7 @@ function verifyAsJSONAndScrub(dirName, testName, data, scrubber, optionsOverride
275
242
  * @param {Object} [optionsOverride]
276
243
  */
277
244
  function verifyWithControl(namer, writer, reporterFactory, optionsOverride) {
278
- const newOptions = cfg.getConfig(optionsOverride);
245
+ const newOptions = (0, config_1.getConfig)(optionsOverride);
279
246
  const loader = reporterFactory ||
280
247
  function () {
281
248
  return [ReporterFactory_1.ReporterFactory.loadReporter(newOptions.reporters)];
@@ -1,5 +1,7 @@
1
1
  export declare class FinalMessages {
2
2
  static addMessage(message: any): void;
3
3
  static addKeyMessage(key: any, message: any): void;
4
+ /** Removes all messages; intended for tests only. */
5
+ static clear(): void;
4
6
  static getMessages(): any[];
5
7
  }
@@ -9,6 +9,11 @@ class FinalMessages {
9
9
  static addKeyMessage(key, message) {
10
10
  messages[key] = message;
11
11
  }
12
+ /** Removes all messages; intended for tests only. */
13
+ static clear() {
14
+ messages.length = 0;
15
+ Object.keys(messages).forEach((key) => delete messages[key]);
16
+ }
12
17
  static getMessages() {
13
18
  return Object.keys(messages).map((x) => messages[x]);
14
19
  }
@@ -1,41 +1,11 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
35
5
  Object.defineProperty(exports, "__esModule", { value: true });
36
6
  exports.ApprovedFileLog = void 0;
37
- const fs = __importStar(require("fs"));
38
- const path = __importStar(require("path"));
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
39
9
  const JestSetup_1 = require("../Providers/Jest/JestSetup");
40
10
  const JestUtils_1 = require("../Utilities/JestUtils");
41
11
  const LogUtils_1 = require("./LogUtils");
@@ -54,15 +24,15 @@ class ApprovedFileLog {
54
24
  }
55
25
  static forceClearLogFile() {
56
26
  const logFilePath = this.getLogFilePath();
57
- fs.writeFileSync(logFilePath, "");
27
+ fs_1.default.writeFileSync(logFilePath, "");
58
28
  }
59
29
  static getLogFilePath() {
60
- return path.join(LogUtils_1.LogUtils.ensureTempDirectoryExists(), ".approved_files.log");
30
+ return path_1.default.join(LogUtils_1.LogUtils.ensureTempDirectoryExists(), ".approved_files.log");
61
31
  }
62
32
  static log(filePath) {
63
33
  this.clearLogFile();
64
34
  const logFilePath = this.getLogFilePath();
65
- fs.appendFileSync(logFilePath, filePath + "\n");
35
+ fs_1.default.appendFileSync(logFilePath, filePath + "\n");
66
36
  }
67
37
  }
68
38
  exports.ApprovedFileLog = ApprovedFileLog;
@@ -1,41 +1,11 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
35
5
  Object.defineProperty(exports, "__esModule", { value: true });
36
6
  exports.FailedFileLog = void 0;
37
- const fs = __importStar(require("fs"));
38
- const path = __importStar(require("path"));
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
39
9
  const JestUtils_1 = require("../Utilities/JestUtils");
40
10
  const LogUtils_1 = require("./LogUtils");
41
11
  let runOnce = false;
@@ -48,15 +18,15 @@ class FailedFileLog {
48
18
  this.forceClearFileLog();
49
19
  }
50
20
  static forceClearFileLog() {
51
- fs.writeFileSync(this.getLogFilePath(), "");
21
+ fs_1.default.writeFileSync(this.getLogFilePath(), "");
52
22
  }
53
23
  static getLogFilePath() {
54
- return path.join(LogUtils_1.LogUtils.ensureTempDirectoryExists(), ".failed_comparison.log");
24
+ return path_1.default.join(LogUtils_1.LogUtils.ensureTempDirectoryExists(), ".failed_comparison.log");
55
25
  }
56
26
  static log(approved, received) {
57
27
  const logFilePath = this.getLogFilePath();
58
28
  const logEntry = `${received} -> ${approved}\n`;
59
- fs.appendFileSync(logFilePath, logEntry);
29
+ fs_1.default.appendFileSync(logFilePath, logEntry);
60
30
  }
61
31
  static touch() {
62
32
  this.clearLogFile();
@@ -1,43 +1,13 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
35
5
  Object.defineProperty(exports, "__esModule", { value: true });
36
6
  exports.beforeEachVerifierBase = beforeEachVerifierBase;
37
- const fs = __importStar(require("fs"));
38
- const _ = __importStar(require("lodash"));
39
- const aUtils = __importStar(require("../AUtils"));
40
- const cfg = __importStar(require("../config"));
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const lodash_1 = __importDefault(require("lodash"));
9
+ const AUtils_1 = require("../AUtils");
10
+ const config_1 = require("../config");
41
11
  const FileApprover_1 = require("../FileApprover");
42
12
  const ReporterFactory_1 = require("../Reporting/ReporterFactory");
43
13
  const StringWriter_1 = require("../StringWriter");
@@ -46,25 +16,25 @@ function beforeEachLoaderFunction(Namer, dirName, that) {
46
16
  that.verify = verify;
47
17
  that.verifyAsJSON = verifyAsJSON;
48
18
  function getCurrentReporters(options) {
49
- options = options || cfg.currentConfig();
19
+ options = options || (0, config_1.currentConfig)();
50
20
  return ReporterFactory_1.ReporterFactory.loadAllReporters(options.reporters);
51
21
  }
52
22
  function verify(data, overrideOptions) {
53
23
  const namer = new Namer(this, dirName);
54
- const newOptions = _.defaults(overrideOptions || {}, cfg.currentConfig());
24
+ const newOptions = lodash_1.default.defaults(overrideOptions || {}, (0, config_1.currentConfig)());
55
25
  const reporterFactory = () => getCurrentReporters(newOptions);
56
26
  const writer = new StringWriter_1.StringWriter(newOptions, data);
57
27
  FileApprover_1.FileApprover.verify(namer, writer, reporterFactory);
58
28
  }
59
29
  function verifyAsJSON(data, overrideOptions) {
60
- this.verify(aUtils.stringifyKeysInOrder(data), overrideOptions);
30
+ this.verify((0, AUtils_1.stringifyKeysInOrder)(data), overrideOptions);
61
31
  }
62
32
  }
63
33
  function ensureDirectoryExists(dirName, usageSample) {
64
- if (!fs.existsSync(dirName)) {
65
- fs.mkdirSync(dirName);
34
+ if (!fs_1.default.existsSync(dirName)) {
35
+ fs_1.default.mkdirSync(dirName);
66
36
  }
67
- if (!fs.lstatSync(dirName).isDirectory()) {
37
+ if (!fs_1.default.lstatSync(dirName).isDirectory()) {
68
38
  throw new Error(`Invalid directory [${dirName}]. Try using the following syntax. > ${usageSample}`);
69
39
  }
70
40
  }
@@ -1,42 +1,9 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.verify = verify;
37
4
  exports.verifyAsJson = verifyAsJson;
38
5
  exports.verifyAll = verifyAll;
39
- const approvals = __importStar(require("../../Approvals"));
6
+ const Approvals_1 = require("../../Approvals");
40
7
  const Options_1 = require("../../Core/Options");
41
8
  const StringWriter_1 = require("../../StringWriter");
42
9
  const Printers_1 = require("../../Utilities/Printers");
@@ -48,11 +15,11 @@ function verify(sut, options) {
48
15
  }
49
16
  options = options || new Options_1.Options();
50
17
  options = options.withNamer((0, JestNamer_1.getJestNamer)());
51
- const config = options.getConfig(approvals.getConfig());
18
+ const config = options.getConfig((0, Approvals_1.getConfig)());
52
19
  const scrubbed = options.scrub(`${sut}`);
53
20
  const writer = new StringWriter_1.StringWriter(config, scrubbed, options.forFile().getFileExtension());
54
21
  const namer = options.getNamer();
55
- approvals.verifyWithControl(namer, writer, null, config);
22
+ (0, Approvals_1.verifyWithControl)(namer, writer, null, config);
56
23
  }
57
24
  function verifyAsJson(data, options) {
58
25
  const text = (0, Printers_1.printJson)(data);
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
@@ -42,7 +9,7 @@ exports.getNamer = getNamer;
42
9
  exports.verify = verify;
43
10
  exports.verifyAsJson = verifyAsJson;
44
11
  exports.verifyAll = verifyAll;
45
- const approvals = __importStar(require("../../Approvals"));
12
+ const Approvals_1 = require("../../Approvals");
46
13
  const Options_1 = require("../../Core/Options");
47
14
  const StringWriter_1 = __importDefault(require("../../StringWriter"));
48
15
  const Printers_1 = require("../../Utilities/Printers");
@@ -77,10 +44,10 @@ function verify(sut, options) {
77
44
  }
78
45
  options = options || new Options_1.Options();
79
46
  options = options.withNamer(getNamer());
80
- const config = options.getConfig(approvals.getConfig());
47
+ const config = options.getConfig((0, Approvals_1.getConfig)());
81
48
  const scrubbed = options.scrub(`${sut}`);
82
49
  const writer = new StringWriter_1.default(config, scrubbed, options.forFile().getFileExtension());
83
- approvals.verifyWithControl(namer, writer, null, config);
50
+ (0, Approvals_1.verifyWithControl)(namer, writer, null, config);
84
51
  }
85
52
  function verifyAsJson(data, options) {
86
53
  const text = (0, Printers_1.printJson)(data);
@@ -1,42 +1,9 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.verify = verify;
37
4
  exports.verifyAsJson = verifyAsJson;
38
5
  exports.verifyAll = verifyAll;
39
- const approvals = __importStar(require("../../Approvals"));
6
+ const Approvals_1 = require("../../Approvals");
40
7
  const Options_1 = require("../../Core/Options");
41
8
  const StringWriter_1 = require("../../StringWriter");
42
9
  const Printers_1 = require("../../Utilities/Printers");
@@ -48,11 +15,11 @@ function verify(sut, options) {
48
15
  }
49
16
  options = options || new Options_1.Options();
50
17
  options = options.withNamer((0, VitestNamer_1.getVitestNamer)());
51
- const config = options.getConfig(approvals.getConfig());
18
+ const config = options.getConfig((0, Approvals_1.getConfig)());
52
19
  const scrubbed = options.scrub(`${sut}`);
53
20
  const writer = new StringWriter_1.StringWriter(config, scrubbed, options.forFile().getFileExtension());
54
21
  const namer = options.getNamer();
55
- approvals.verifyWithControl(namer, writer, null, config);
22
+ (0, Approvals_1.verifyWithControl)(namer, writer, null, config);
56
23
  }
57
24
  function verifyAsJson(data, options) {
58
25
  const text = (0, Printers_1.printJson)(data);
@@ -1,45 +1,12 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
38
5
  Object.defineProperty(exports, "__esModule", { value: true });
39
6
  exports.GenericDiffReporterBase = void 0;
40
- const childProcess = __importStar(require("child_process"));
41
- const fs = __importStar(require("fs"));
42
- const autils = __importStar(require("../AUtils"));
7
+ const child_process_1 = __importDefault(require("child_process"));
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const AUtils_1 = require("../AUtils");
43
10
  const ReportLaunchingCircuitBreaker_1 = __importDefault(require("./ReportLaunchingCircuitBreaker"));
44
11
  class GenericDiffReporterBase {
45
12
  constructor(name) {
@@ -58,7 +25,7 @@ class GenericDiffReporterBase {
58
25
  return this._reporterFileLookedUpAndFound;
59
26
  }
60
27
  this._reporterFileLookedUp = true;
61
- if (!fs.existsSync(this.exePath)) {
28
+ if (!fs_1.default.existsSync(this.exePath)) {
62
29
  return false;
63
30
  }
64
31
  this._reporterFileLookedUpAndFound = true;
@@ -71,15 +38,15 @@ class GenericDiffReporterBase {
71
38
  if (!this.isReporterAvailable()) {
72
39
  return false;
73
40
  }
74
- autils.assertFileExists(fileName);
41
+ (0, AUtils_1.assertFileExists)(fileName);
75
42
  if (this.canImageDiff()) {
76
43
  return true;
77
44
  }
78
- const isBinary = autils.isBinaryFile(fileName);
45
+ const isBinary = (0, AUtils_1.isBinaryFile)(fileName);
79
46
  return !isBinary;
80
47
  }
81
48
  spawn(exe, args, cmdOptions) {
82
- const process = childProcess.spawn(exe, args, cmdOptions);
49
+ const process = child_process_1.default.spawn(exe, args, cmdOptions);
83
50
  let stdout = "";
84
51
  let stderr = "";
85
52
  process.stdout.on("data", (data) => {
@@ -103,7 +70,7 @@ class GenericDiffReporterBase {
103
70
  return process;
104
71
  }
105
72
  spawnSync(exe, args, cmdOptions) {
106
- const result = childProcess.spawnSync(exe, args, cmdOptions);
73
+ const result = child_process_1.default.spawnSync(exe, args, cmdOptions);
107
74
  const stdout = result.stdout.toString();
108
75
  const stderr = result.stderr.toString();
109
76
  if (stdout) {
@@ -122,7 +89,7 @@ class GenericDiffReporterBase {
122
89
  const spawnMethod = options.blockUntilReporterExits
123
90
  ? this.spawnSync.bind(this)
124
91
  : this.spawn.bind(this);
125
- autils.createEmptyFileIfNotExists(approved);
92
+ (0, AUtils_1.createEmptyFileIfNotExists)(approved);
126
93
  const { cmdOptions, args } = this.getCommandArguments(approved, received, options);
127
94
  console.log("CMD: ", this.exePath, args.join(" "));
128
95
  spawnMethod(this.exePath, args, cmdOptions);
@@ -1,5 +1,7 @@
1
1
  export declare class ReportLaunchingCircuitBreaker {
2
2
  static setMaxLaunch(value: number): void;
3
+ /** Restores the initial state; intended for tests only. */
4
+ static reset(): void;
3
5
  static get currentCount(): number;
4
6
  static notifyLaunched(): void;
5
7
  static isLimitExceeded(): boolean;
@@ -13,6 +13,12 @@ class ReportLaunchingCircuitBreaker {
13
13
  static setMaxLaunch(value) {
14
14
  maxLaunch = value;
15
15
  }
16
+ /** Restores the initial state; intended for tests only. */
17
+ static reset() {
18
+ maxLaunch = 10;
19
+ currentCount = 0;
20
+ reroutedCount = 0;
21
+ }
16
22
  static get currentCount() {
17
23
  return currentCount;
18
24
  }
@@ -1,38 +1,8 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- const shelljs = __importStar(require("shelljs"));
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ const shelljs_1 = __importDefault(require("shelljs"));
36
6
  const AUtils_1 = require("../../AUtils");
37
7
  const osTools_1 = require("../../osTools");
38
8
  const GenericDiffReporterBase_1 = require("../GenericDiffReporterBase");
@@ -42,7 +12,7 @@ class Reporter extends GenericDiffReporterBase_1.GenericDiffReporterBase {
42
12
  let app = null;
43
13
  if (osTools_1.platform.isMac) {
44
14
  try {
45
- app = shelljs.ls("/Applications/DiffMerge.app/Contents/MacOS/DiffMerge")[0];
15
+ app = shelljs_1.default.ls("/Applications/DiffMerge.app/Contents/MacOS/DiffMerge")[0];
46
16
  }
47
17
  catch (err) {
48
18
  console.error(err);
@@ -10,7 +10,6 @@ class GitDiffReporter extends GenericDiffReporterBase_1.GenericDiffReporterBase
10
10
  report(approved, received, options) {
11
11
  options = options || {};
12
12
  (0, AUtils_1.createEmptyFileIfNotExists)(approved);
13
- console.log(this.exePath);
14
13
  options.cmdArgs = ["diff", "--no-index", "--", received, approved];
15
14
  // force gitdiff to run synchronously so our console output
16
15
  // stays in order of test execution.
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const fs_1 = __importDefault(require("fs"));
7
- const diff_1 = __importDefault(require("diff"));
7
+ const diff_1 = require("diff");
8
8
  const AUtils_1 = require("../../AUtils");
9
9
  const ConsoleUtils_1 = require("../../Utilities/ConsoleUtils");
10
10
  function colorByChangeType(part) {
@@ -30,7 +30,7 @@ class NodeDiffReporter {
30
30
  const receivedText = fs_1.default.readFileSync(received).toString();
31
31
  console.log(`*******************************************`);
32
32
  console.log(`* Showing diff for ${approved} vs ${received}\n`);
33
- const diff = diff_1.default.diffChars(approvedText, receivedText);
33
+ const diff = (0, diff_1.diffChars)(approvedText, receivedText);
34
34
  diff.forEach((part) => process.stdout.write(colorByChangeType(part)));
35
35
  console.log(`\n* End of diff for ${approved} vs ${received}`);
36
36
  console.log(`*******************************************\n\n`);
@@ -11,13 +11,9 @@ const GenericDiffReporterBase_1 = require("../GenericDiffReporterBase");
11
11
  const MAC_APPLICATIONS_LAUNCHER = "/Applications/p4merge.app/Contents/Resources/launchp4merge";
12
12
  const HOMEBREW_CASK_FOLDER = "/opt/homebrew-cask/Caskroom/p4merge";
13
13
  function findInMacApplications() {
14
- try {
15
- return shelljs_1.default.ls(MAC_APPLICATIONS_LAUNCHER)[0];
16
- }
17
- catch (err) {
18
- console.error(err);
19
- return null;
20
- }
14
+ return fs_1.default.existsSync(MAC_APPLICATIONS_LAUNCHER)
15
+ ? MAC_APPLICATIONS_LAUNCHER
16
+ : null;
21
17
  }
22
18
  function findInHomebrewCask() {
23
19
  try {
@@ -1,46 +1,16 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
35
5
  Object.defineProperty(exports, "__esModule", { value: true });
36
6
  exports.StringWriter = void 0;
37
- const fs = __importStar(require("fs"));
38
- const path = __importStar(require("path"));
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
39
9
  const mkdirp_1 = require("mkdirp");
40
- const autils = __importStar(require("./AUtils"));
10
+ const AUtils_1 = require("./AUtils");
41
11
  const lineEndingRegex = new RegExp("\r?\n", "g");
42
12
  function normalizeLineEndings(lineEnding, value) {
43
- if (autils.isBinaryFile(value)) {
13
+ if ((0, AUtils_1.isBinaryFile)(value)) {
44
14
  return value;
45
15
  }
46
16
  return value.replace(lineEndingRegex, lineEnding);
@@ -58,8 +28,8 @@ class StringWriter {
58
28
  return this.ext;
59
29
  }
60
30
  write(filePath) {
61
- const dir = path.dirname(path.normalize(filePath));
62
- if (!fs.existsSync(dir)) {
31
+ const dir = path_1.default.dirname(path_1.default.normalize(filePath));
32
+ if (!fs_1.default.existsSync(dir)) {
63
33
  (0, mkdirp_1.sync)(dir);
64
34
  }
65
35
  if (this.config.normalizeLineEndingsTo !== false &&
@@ -75,7 +45,7 @@ class StringWriter {
75
45
  this.outputText += this.config.EOL;
76
46
  }
77
47
  }
78
- fs.writeFileSync(filePath, this.outputText);
48
+ fs_1.default.writeFileSync(filePath, this.outputText);
79
49
  }
80
50
  }
81
51
  exports.StringWriter = StringWriter;
@@ -1,41 +1,11 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
35
5
  Object.defineProperty(exports, "__esModule", { value: true });
36
6
  exports.BinaryWriter = void 0;
37
- const fs = __importStar(require("fs"));
38
- const path = __importStar(require("path"));
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
39
9
  const magic_bytes_js_1 = require("magic-bytes.js");
40
10
  const mkdirp_1 = require("mkdirp");
41
11
  const legacyApprovalFileExtensions = new Map([
@@ -56,11 +26,11 @@ class BinaryWriter {
56
26
  return this._ext;
57
27
  }
58
28
  write(filePath) {
59
- const dir = path.dirname(path.normalize(filePath));
60
- if (!fs.existsSync(dir)) {
29
+ const dir = path_1.default.dirname(path_1.default.normalize(filePath));
30
+ if (!fs_1.default.existsSync(dir)) {
61
31
  (0, mkdirp_1.sync)(dir);
62
32
  }
63
- fs.writeFileSync(filePath, this.outputData);
33
+ fs_1.default.writeFileSync(filePath, this.outputData);
64
34
  }
65
35
  }
66
36
  exports.BinaryWriter = BinaryWriter;
package/lib/config.js CHANGED
@@ -1,37 +1,7 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
35
5
  Object.defineProperty(exports, "__esModule", { value: true });
36
6
  exports.defaultConfig = void 0;
37
7
  exports.getHomeApprovalConfig = getHomeApprovalConfig;
@@ -39,11 +9,11 @@ exports.getConfig = getConfig;
39
9
  exports.configure = configure;
40
10
  exports.currentConfig = currentConfig;
41
11
  exports.reset = reset;
42
- const fs = __importStar(require("fs"));
43
- const os = __importStar(require("os"));
44
- const path = __importStar(require("path"));
45
- const yaml = __importStar(require("js-yaml"));
46
- const _ = __importStar(require("lodash"));
12
+ const fs_1 = __importDefault(require("fs"));
13
+ const os_1 = __importDefault(require("os"));
14
+ const path_1 = __importDefault(require("path"));
15
+ const js_yaml_1 = __importDefault(require("js-yaml"));
16
+ const lodash_1 = __importDefault(require("lodash"));
47
17
  const ReportLaunchingCircuitBreaker_1 = require("./Reporting/ReportLaunchingCircuitBreaker");
48
18
  // begin-snippet: default_config
49
19
  exports.defaultConfig = {
@@ -59,7 +29,7 @@ exports.defaultConfig = {
59
29
  normalizeLineEndingsTo: false,
60
30
  failOnLineEndingDifferences: false,
61
31
  appendEOL: true,
62
- EOL: os.EOL,
32
+ EOL: os_1.default.EOL,
63
33
  errorOnStaleApprovedFiles: true,
64
34
  shouldIgnoreStaleApprovedFile: () => false,
65
35
  stripBOM: false,
@@ -69,11 +39,11 @@ exports.defaultConfig = {
69
39
  };
70
40
  // end-snippet
71
41
  function getHomeApprovalConfig() {
72
- const homeConfigPath = path.join(os.homedir(), ".approvalsConfig");
73
- if (fs.existsSync(homeConfigPath)) {
74
- const configFileData = fs.readFileSync(homeConfigPath).toString();
42
+ const homeConfigPath = path_1.default.join(os_1.default.homedir(), ".approvalsConfig");
43
+ if (fs_1.default.existsSync(homeConfigPath)) {
44
+ const configFileData = fs_1.default.readFileSync(homeConfigPath).toString();
75
45
  try {
76
- return yaml.load(configFileData);
46
+ return js_yaml_1.default.load(configFileData);
77
47
  }
78
48
  catch (ex) {
79
49
  throw new Error("Error parsing " + homeConfigPath + ". " + ex);
@@ -84,7 +54,7 @@ function getHomeApprovalConfig() {
84
54
  let currentConfigObj;
85
55
  function getConfig(configOverrides) {
86
56
  const homeConfig = getHomeApprovalConfig() || {};
87
- const resultConfig = _.defaults(configOverrides || {}, currentConfigObj || {}, homeConfig, exports.defaultConfig);
57
+ const resultConfig = lodash_1.default.defaults(configOverrides || {}, currentConfigObj || {}, homeConfig, exports.defaultConfig);
88
58
  return resultConfig;
89
59
  }
90
60
  function configure(overrideOptions) {
@@ -96,7 +66,7 @@ function currentConfig() {
96
66
  return currentConfigObj;
97
67
  }
98
68
  function reset() {
99
- currentConfigObj = _.defaults({}, getHomeApprovalConfig(), exports.defaultConfig);
69
+ currentConfigObj = lodash_1.default.defaults({}, getHomeApprovalConfig(), exports.defaultConfig);
100
70
  }
101
71
  currentConfigObj = getConfig();
102
72
  function processConfig(config) {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "description": "Approval Tests Library - Capturing Human Intelligence",
7
- "version": "7.6.2",
7
+ "version": "7.6.3",
8
8
  "homepage": "http://approvaltests.com",
9
9
  "author": {
10
10
  "name": "Jason Jarrett",
@@ -45,7 +45,7 @@
45
45
  "scripts": {
46
46
  "build": "tsc",
47
47
  "prepack": "npm run build",
48
- "test": "npm run lint && npm run test:suites --",
48
+ "test": "npm run --silent lint && npm run --silent test:suites --",
49
49
  "test:suites": "node scripts/test.cjs",
50
50
  "vitest": "node scripts/test-isolated.cjs vitest",
51
51
  "test2": "npm run mocha && npm run lint",
@@ -54,13 +54,9 @@
54
54
  "lint:staged": "lint-staged",
55
55
  "mocha": "node scripts/test-isolated.cjs mocha",
56
56
  "coverage": "node scripts/test-isolated.cjs mocha --coverage",
57
- "jest": "node scripts/test-isolated.cjs jest"
57
+ "jest": "node scripts/test-isolated.cjs jest",
58
+ "prepare": "husky"
58
59
  },
59
- "pre-commit": [
60
- "lint:staged",
61
- "build",
62
- "test:suites"
63
- ],
64
60
  "lint-staged": {
65
61
  "*.{js,mjs,ts,mts}": "eslint --fix"
66
62
  },
@@ -78,8 +74,7 @@
78
74
  "marked-terminal-renderer": "^2.2.0",
79
75
  "minimist": "^1.2.8",
80
76
  "mkdirp": "^3.0.1",
81
- "shelljs": "^0.10.0",
82
- "temp": "^0.9.4"
77
+ "shelljs": "^0.10.0"
83
78
  },
84
79
  "devDependencies": {
85
80
  "@types/chai": "^5.0.1",
@@ -88,16 +83,17 @@
88
83
  "@typescript-eslint/eslint-plugin": "^8.17.0",
89
84
  "@typescript-eslint/parser": "^8.17.0",
90
85
  "chai": "^6.0.1",
86
+ "concurrently": "^10.0.7",
91
87
  "eslint": "^10.2.1",
92
88
  "eslint-plugin-import-x": "^4.18.1",
93
89
  "eslint-plugin-promise": "^7.2.1",
94
90
  "globals": "^17.14.0",
91
+ "husky": "^9.1.7",
95
92
  "jscpd": "^5.4.3",
96
93
  "jsdoc-to-markdown": "^9.1.1",
97
94
  "knip": "^6.45.1",
98
95
  "lint-staged": "^17.6.0",
99
96
  "nyc": "^18.0.0",
100
- "pre-commit": "^2.0.0",
101
97
  "prettier": "^3.4.2",
102
98
  "sinon": "^22.0.0",
103
99
  "ts-morph": "^28.0.0",