Skip to content

Commit

Permalink
cleanup cli
Browse files Browse the repository at this point in the history
  • Loading branch information
gvkhna committed May 29, 2024
1 parent 60c286b commit a329635
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 4 additions & 4 deletions cli/warpdive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand All @@ -30,8 +30,8 @@ function runBinary(...args) {
}

module.exports = {
BINARY_DISTRIBUTION_PACKAGES,
binaryName,
getBinaryPath,
platformSpecificPackageName,
runBinary
}
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 {BINARY_DISTRIBUTION_PACKAGES, binaryName} = require('./index')
const {binaryName, platformSpecificPackageName} = 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

// 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)

Expand Down

0 comments on commit a329635

Please sign in to comment.