diff --git a/lib/utils.js b/lib/utils.js index bc955b8..23add21 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -20,7 +20,7 @@ var which = require("which"); * @return {Promise} */ function normalizeBinary (binaryPath, platform, arch) { - return new Promise(function(resolve, reject) { + return new Promise(function(resolve) { platform = platform || os.platform(); arch = arch || os.arch(); binaryPath = binaryPath || process.env.JPM_FIREFOX_BINARY || "firefox"; @@ -66,13 +66,7 @@ function normalizeBinary (binaryPath, platform, arch) { // On linux but no path yet, use which to try and find the binary else if (platform.indexOf("linux") !== -1) { binaryPath = normalizeBinary.appNames[binaryPath + " on linux"] || binaryPath; - which(binaryPath, function(err, resolvedPath) { - if (err) { - reject(err); - } else { - resolve(resolvedPath); - } - }); + resolve(which(binaryPath)); return; } // No action needed on windows if it's an executable already diff --git a/package-lock.json b/package-lock.json index f8b2546..b92f6de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -376,14 +376,6 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "is-absolute": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-0.1.7.tgz", - "integrity": "sha1-hHSREZ/MtftDYhfMc39/qtUPYD8=", - "requires": { - "is-relative": "^0.1.0" - } - }, "is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -426,11 +418,6 @@ "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", "dev": true }, - "is-relative": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-0.1.3.tgz", - "integrity": "sha1-kF/uiuhvRbPsYUvDwVyGnfCHboI=" - }, "is-unicode-supported": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", @@ -438,9 +425,9 @@ "dev": true }, "isexe": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-1.1.2.tgz", - "integrity": "sha1-NvPiLmB1CSD15yQaR2qMakInWtA=" + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz", + "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==" }, "js-yaml": { "version": "4.1.0", @@ -714,12 +701,11 @@ "dev": true }, "which": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/which/-/which-1.2.4.tgz", - "integrity": "sha1-FVf5YIBgTlsRs1meufRbUKnv1yI=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/which/-/which-4.0.0.tgz", + "integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==", "requires": { - "is-absolute": "^0.1.7", - "isexe": "^1.1.1" + "isexe": "^3.1.1" } }, "winreg": { diff --git a/package.json b/package.json index 85cf252..448a20a 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "dependencies": { "commander": "2.9.0", "shell-quote": "1.8.1", - "which": "1.2.4", + "which": "^4.0.0", "winreg": "0.0.12" }, "devDependencies": { diff --git a/test/run/test.utils.js b/test/run/test.utils.js index 0f335bc..b80124f 100644 --- a/test/run/test.utils.js +++ b/test/run/test.utils.js @@ -12,6 +12,10 @@ var sandbox = require('sandboxed-module'); var binary = utils.normalizeBinary; sandbox.configure({ + requires: { + // sandboxed-module is unable to find this module directly + "fs/promises": require("fs/promises"), + }, globals: { // As of Node 12.x, the process global is no longer an enumerable property of the global. // https://github.com/nodejs/node/pull/26882 @@ -160,9 +164,7 @@ describe("lib/utils", function () { var binary = sandbox.require("../../lib/utils", { requires: { - which: function(bin, callback) { - callback(null, "/usr/bin/" + bin); - } + which: async (bin) => "/usr/bin/" + bin } }).normalizeBinary; @@ -247,9 +249,7 @@ describe("lib/utils", function () { var binary = sandbox.require("../../lib/utils", { requires: { - which: function(bin, callback) { - callback(null, "/usr/bin/" + bin); - } + which: async (bin) => "/usr/bin/" + bin } }).normalizeBinary;