diff --git a/__tests__/bin-wrapper.test.js b/__tests__/bin-wrapper.test.js deleted file mode 100644 index c17e40f..0000000 --- a/__tests__/bin-wrapper.test.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; - -const binWrapper = require("../src/bin-wrapper"); -const binCheck = require("bin-check"); - -describe("bin wrapper instances", () => { - it("should work", () => - Promise.all([ - expect(binCheck(binWrapper.cjpeg.path(), ["-version"])).resolves.toBe( - true - ), - expect(binCheck(binWrapper.djpeg.path(), ["-version"])).resolves.toBe( - true - ), - expect(binCheck(binWrapper.jpegtran.path(), ["-version"])).resolves.toBe( - true - ), - expect(binCheck(binWrapper.rdjpgcom.path(), ["-help"])).rejects.toThrow( - "rdjpgcom displays any textual comments in a JPEG file." - ), - expect(binCheck(binWrapper.tjbench.path(), ["-version"])).rejects.toThrow( - "tjbench" - ), - expect( - binCheck(binWrapper.wrjpgcom.path(), ["-version"]) - ).rejects.toThrow("wrjpgcom inserts a textual comment in a JPEG file.") - ])); -}); diff --git a/__tests__/bin-wrappers.test.js b/__tests__/bin-wrappers.test.js new file mode 100644 index 0000000..4f05499 --- /dev/null +++ b/__tests__/bin-wrappers.test.js @@ -0,0 +1,28 @@ +"use strict"; + +const binWrappers = require("../src/bin-wrappers"); +const binCheck = require("bin-check"); + +describe("bin wrapper instances", () => { + it("should work", () => + Promise.all([ + expect(binCheck(binWrappers.cjpeg.path(), ["-version"])).resolves.toBe( + true + ), + expect(binCheck(binWrappers.djpeg.path(), ["-version"])).resolves.toBe( + true + ), + expect(binCheck(binWrappers.jpegtran.path(), ["-version"])).resolves.toBe( + true + ), + expect(binCheck(binWrappers.rdjpgcom.path(), ["-help"])).rejects.toThrow( + "rdjpgcom displays any textual comments in a JPEG file." + ), + expect( + binCheck(binWrappers.tjbench.path(), ["-version"]) + ).rejects.toThrow("tjbench"), + expect( + binCheck(binWrappers.wrjpgcom.path(), ["-version"]) + ).rejects.toThrow("wrjpgcom inserts a textual comment in a JPEG file.") + ])); +}); diff --git a/src/bin-wrapper.js b/src/bin-wrapper.js deleted file mode 100644 index 64b8344..0000000 --- a/src/bin-wrapper.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; - -const path = require("path"); -const BinWrapper = require("bin-wrapper"); - -const dest = path.join(__dirname, "../vendor"); -const isWin = process.platform === "win32"; - -module.exports = { - cjpeg: new BinWrapper().dest(dest).use(isWin ? "cjpeg.exe" : "cjpeg"), - djpeg: new BinWrapper().dest(dest).use(isWin ? "djpeg.exe" : "djpeg"), - jpegtran: new BinWrapper() - .dest(dest) - .use(isWin ? "jpegtran.exe" : "jpegtran"), - rdjpgcom: new BinWrapper() - .dest(dest) - .use(isWin ? "rdjpgcom.exe" : "rdjpgcom"), - tjbench: new BinWrapper().dest(dest).use(isWin ? "tjbench.exe" : "tjbench"), - wrjpgcom: new BinWrapper().dest(dest).use(isWin ? "wrjpgcom.exe" : "wrjpgcom") -}; diff --git a/src/bin-wrappers.js b/src/bin-wrappers.js new file mode 100644 index 0000000..0bd82d2 --- /dev/null +++ b/src/bin-wrappers.js @@ -0,0 +1,22 @@ +"use strict"; + +const path = require("path"); +const BinWrappers = require("bin-wrapper"); + +const dest = path.join(__dirname, "../vendor"); +const isWin = process.platform === "win32"; + +module.exports = { + cjpeg: new BinWrappers().dest(dest).use(isWin ? "cjpeg.exe" : "cjpeg"), + djpeg: new BinWrappers().dest(dest).use(isWin ? "djpeg.exe" : "djpeg"), + jpegtran: new BinWrappers() + .dest(dest) + .use(isWin ? "jpegtran.exe" : "jpegtran"), + rdjpgcom: new BinWrappers() + .dest(dest) + .use(isWin ? "rdjpgcom.exe" : "rdjpgcom"), + tjbench: new BinWrappers().dest(dest).use(isWin ? "tjbench.exe" : "tjbench"), + wrjpgcom: new BinWrappers() + .dest(dest) + .use(isWin ? "wrjpgcom.exe" : "wrjpgcom") +}; diff --git a/src/index.js b/src/index.js index ded02af..5378fdb 100644 --- a/src/index.js +++ b/src/index.js @@ -1,12 +1,12 @@ "use strict"; -const binaries = require("./bin-wrapper"); +const binWrappers = require("./bin-wrappers"); module.exports = { - cjpeg: binaries.cjpeg.path(), - djpeg: binaries.djpeg.path(), - jpegtran: binaries.jpegtran.path(), - rdjpgcom: binaries.rdjpgcom.path(), - tjbench: binaries.tjbench.path(), - wrjpgcom: binaries.wrjpgcom.path() + cjpeg: binWrappers.cjpeg.path(), + djpeg: binWrappers.djpeg.path(), + jpegtran: binWrappers.jpegtran.path(), + rdjpgcom: binWrappers.rdjpgcom.path(), + tjbench: binWrappers.tjbench.path(), + wrjpgcom: binWrappers.wrjpgcom.path() }; diff --git a/src/install.js b/src/install.js index c3e4aa2..039cc59 100644 --- a/src/install.js +++ b/src/install.js @@ -4,7 +4,7 @@ const fs = require("fs"); const os = require("os"); const binBuild = require("bin-build"); const PQueue = require("p-queue"); -const binWrappers = require("./bin-wrapper"); +const binWrappers = require("./bin-wrappers"); const buildCommands = () => { const cpus = (os.cpus() || { length: 1 }).length;