diff --git a/cli/warpdive/index.js b/cli/warpdive/index.js index 4aa16a9..a387a83 100644 --- a/cli/warpdive/index.js +++ b/cli/warpdive/index.js @@ -11,10 +11,10 @@ const BINARY_DISTRIBUTION_PACKAGES = { // Windows binaries end with .exe so we need to special case them. const binaryName = process.platform === 'win32' ? 'warpdive.exe' : 'warpdive' -function getBinaryPath() { - // Determine package name for this platform - const platformSpecificPackageName = BINARY_DISTRIBUTION_PACKAGES[`${process.platform}-${process.arch}`] +// Determine package name for this platform +const platformSpecificPackageName = BINARY_DISTRIBUTION_PACKAGES[`${process.platform}-${process.arch}`] +function getBinaryPath() { try { // Resolving will fail if the optionalDependency was not installed return require.resolve(`${platformSpecificPackageName}/bin/${binaryName}`) @@ -30,8 +30,8 @@ function runBinary(...args) { } module.exports = { - BINARY_DISTRIBUTION_PACKAGES, binaryName, getBinaryPath, + platformSpecificPackageName, runBinary } diff --git a/cli/warpdive/install.js b/cli/warpdive/install.js index 2574473..7d33e7d 100644 --- a/cli/warpdive/install.js +++ b/cli/warpdive/install.js @@ -3,7 +3,7 @@ const path = require('path') const zlib = require('zlib') const https = require('https') const packageJson = require('./package.json') -const {BINARY_DISTRIBUTION_PACKAGES, binaryName} = require('./index') +const {binaryName, platformSpecificPackageName} = require('./index') // Lookup table for all platforms and binary distribution packages @@ -11,9 +11,6 @@ const {BINARY_DISTRIBUTION_PACKAGES, binaryName} = require('./index') // const BINARY_DISTRIBUTION_VERSION = '1.0.0' const BINARY_DISTRIBUTION_VERSION = packageJson.version -// Determine package name for this platform -const platformSpecificPackageName = BINARY_DISTRIBUTION_PACKAGES[`${process.platform}-${process.arch}`] - // Compute the path we want to emit the fallback binary to const fallbackBinaryPath = path.join(__dirname, binaryName)