diff --git a/cli/warpdive/bin/cli b/cli/warpdive/bin/cli index 547dc55..9a30b2a 100644 --- a/cli/warpdive/bin/cli +++ b/cli/warpdive/bin/cli @@ -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' + }) +} diff --git a/cli/warpdive/install.js b/cli/warpdive/install.js index 7d33e7d..8f00fa4 100644 --- a/cli/warpdive/install.js +++ b/cli/warpdive/install.js @@ -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 +}