From 72936994d04c481212a734637029a1f3d5bf2b78 Mon Sep 17 00:00:00 2001 From: Chan Wu Date: Sat, 9 Nov 2019 16:13:08 +0800 Subject: [PATCH] fix: the `getBinaryPath` function only need to execute once enough (#2620) * fix: the function only need to execute once enough * fix: typo `;` --- lib/binding.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/binding.js b/lib/binding.js index 7af4132ca..8c9ced495 100644 --- a/lib/binding.js +++ b/lib/binding.js @@ -8,7 +8,9 @@ var errors = require('./errors'); * Require binding */ module.exports = function(ext) { - if (!ext.hasBinary(ext.getBinaryPath())) { + var binaryPath = ext.getBinaryPath(); + + if (!ext.hasBinary(binaryPath)) { if (!ext.isSupportedEnvironment()) { throw new Error(errors.unsupportedEnvironment()); } else { @@ -16,5 +18,5 @@ module.exports = function(ext) { } } - return require(ext.getBinaryPath()); + return require(binaryPath); };