Skip to content

Commit

Permalink
update to use fallback binary path
Browse files Browse the repository at this point in the history
  • Loading branch information
gvkhna committed May 29, 2024
1 parent dd4f982 commit 247d361
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion cli/warpdive/bin/cli
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const {isPlatformSpecificPackageInstalled, downloadBinaryFromNpm} = require('../

// Skip downloading the binary if it was already installed via optionalDependencies
if (!isPlatformSpecificPackageInstalled()) {
console.log('Platform specific package not found. Will manually download binary...')
downloadBinaryFromNpm()
.then(() => {
childProcess.execFileSync(getBinaryPath(), process.argv.slice(2), {
Expand Down
7 changes: 6 additions & 1 deletion cli/warpdive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const BINARY_DISTRIBUTION_PACKAGES = {
// Windows binaries end with .exe so we need to special case them.
const binaryName = process.platform === 'win32' ? 'warpdive.exe' : 'warpdive'

// Compute the path we want to emit the fallback binary to
const fallbackBinaryPath = path.join(__dirname, binaryName)

// Determine package name for this platform
const platformSpecificPackageName = BINARY_DISTRIBUTION_PACKAGES[`${process.platform}-${process.arch}`]

Expand All @@ -19,7 +22,8 @@ function getBinaryPath() {
// Resolving will fail if the optionalDependency was not installed
return require.resolve(`${platformSpecificPackageName}/bin/${binaryName}`)
} catch (e) {
return require('path').join(__dirname, '..', binaryName)
return fallbackBinaryPath
// return require('path').join(__dirname, '..', binaryName)
}
}

Expand All @@ -31,6 +35,7 @@ function runBinary(...args) {

module.exports = {
binaryName,
fallbackBinaryPath,
getBinaryPath,
platformSpecificPackageName,
runBinary
Expand Down
5 changes: 1 addition & 4 deletions cli/warpdive/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ const path = require('path')
const zlib = require('zlib')
const https = require('https')
const packageJson = require('./package.json')
const {binaryName, platformSpecificPackageName} = require('./index')
const {binaryName, platformSpecificPackageName, fallbackBinaryPath} = require('./index')

// Lookup table for all platforms and binary distribution packages

// Adjust the version you want to install. You can also make this dynamic.
// const BINARY_DISTRIBUTION_VERSION = '1.0.0'
const BINARY_DISTRIBUTION_VERSION = packageJson.version

// Compute the path we want to emit the fallback binary to
const fallbackBinaryPath = path.join(__dirname, binaryName)

function makeRequest(url) {
return new Promise((resolve, reject) => {
https
Expand Down

0 comments on commit 247d361

Please sign in to comment.