Skip to content

Commit

Permalink
added cli fallback to download binary
Browse files Browse the repository at this point in the history
  • Loading branch information
gvkhna committed May 29, 2024
1 parent a329635 commit dd4f982
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
22 changes: 19 additions & 3 deletions cli/warpdive/bin/cli
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
#!/usr/bin/env node

const childProcess = require('child_process')
const {getBinaryPath} = require('../index')
const {isPlatformSpecificPackageInstalled, downloadBinaryFromNpm} = require('../install')

require('child_process').execFileSync(getBinaryPath(), process.argv.slice(2), {
stdio: 'inherit'
})
// 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), {
stdio: 'inherit'
})
})
.catch((error) => {
console.log('Failed to download and execute the binary:', error)
})
} else {
childProcess.execFileSync(getBinaryPath(), process.argv.slice(2), {
stdio: 'inherit'
})
}
5 changes: 5 additions & 0 deletions cli/warpdive/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,8 @@ if (!isPlatformSpecificPackageInstalled()) {
} else {
console.log('Platform specific package already installed. Will fall back to manually downloading binary.')
}

module.exports = {
isPlatformSpecificPackageInstalled,
downloadBinaryFromNpm
}

0 comments on commit dd4f982

Please sign in to comment.