@approval-tests/approvals 7.5.10 → 7.5.11

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.
@@ -32,23 +32,31 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
35
  Object.defineProperty(exports, "__esModule", { value: true });
39
36
  exports.BinaryWriter = void 0;
40
37
  const fs = __importStar(require("fs"));
41
38
  const path = __importStar(require("path"));
42
39
  const mkdirp_1 = require("mkdirp");
43
- const file_type_1 = __importDefault(require("file-type")); // Assuming fileType provides synchronous methods
40
+ const magic_bytes_js_1 = require("magic-bytes.js");
44
41
  class BinaryWriter {
45
42
  constructor(outputData) {
46
43
  this.outputData = outputData;
47
44
  }
48
45
  getFileExtension() {
49
46
  if (!this._ext) {
50
- const fileTypeDiscovered = (0, file_type_1.default)(this.outputData);
51
- this._ext = (fileTypeDiscovered === null || fileTypeDiscovered === void 0 ? void 0 : fileTypeDiscovered.ext) || "blob"; // Assuming synchronous call
47
+ // Use the first signature match (for example, zip before jar/docx).
48
+ const extension = (0, magic_bytes_js_1.filetypeextension)(this.outputData)[0] || "blob";
49
+ // Keep existing JPEG and TIFF approval filenames compatible.
50
+ switch (extension) {
51
+ case "jpeg":
52
+ this._ext = "jpg";
53
+ break;
54
+ case "tiff":
55
+ this._ext = "tif";
56
+ break;
57
+ default:
58
+ this._ext = extension;
59
+ }
52
60
  }
53
61
  return this._ext;
54
62
  }
@@ -1,7 +1,7 @@
1
1
  import * as fs from "fs";
2
2
  import * as path from "path";
3
3
  import { sync } from "mkdirp";
4
- import fileType from "file-type"; // Assuming fileType provides synchronous methods
4
+ import { filetypeextension } from "magic-bytes.js";
5
5
  import { Writer } from "../Core/Writer";
6
6
 
7
7
  export class BinaryWriter implements Writer {
@@ -14,8 +14,19 @@ export class BinaryWriter implements Writer {
14
14
 
15
15
  getFileExtension(): string {
16
16
  if (!this._ext) {
17
- const fileTypeDiscovered = fileType(this.outputData);
18
- this._ext = fileTypeDiscovered?.ext || "blob"; // Assuming synchronous call
17
+ // Use the first signature match (for example, zip before jar/docx).
18
+ const extension = filetypeextension(this.outputData)[0] || "blob";
19
+ // Keep existing JPEG and TIFF approval filenames compatible.
20
+ switch (extension) {
21
+ case "jpeg":
22
+ this._ext = "jpg";
23
+ break;
24
+ case "tiff":
25
+ this._ext = "tif";
26
+ break;
27
+ default:
28
+ this._ext = extension;
29
+ }
19
30
  }
20
31
  return this._ext;
21
32
  }
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.5.10",
7
+ "version": "7.5.11",
8
8
  "homepage": "http://approvaltests.com",
9
9
  "author": {
10
10
  "name": "Jason Jarrett",
@@ -53,10 +53,10 @@
53
53
  "callsite": "^1.0.0",
54
54
  "diff": "^9.0.0",
55
55
  "event-stream": "^4.0.1",
56
- "file-type": "^12.4.2",
57
56
  "glob": "^13.0.0",
58
57
  "js-yaml": "^5.1.0",
59
58
  "lodash": "^4.17.21",
59
+ "magic-bytes.js": "^1.13.1",
60
60
  "marked": "^18.0.14",
61
61
  "marked-terminal-renderer": "^2.2.0",
62
62
  "minimist": "^1.2.8",