Skip to content

Commit 9851dec

Browse files
committed
impl: check if the cli exists before running it to spill out the version
The logic for matching the local CLI version with the deployment previously attempted to run the CLI with --version without first verifying that the binary existed. This commit improves that by first checking if the file exists, avoiding the unnecessary overhead of spawning a process for a non-existent binary.
1 parent 811fc85 commit 9851dec

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/main/kotlin/com/coder/toolbox/cli/CoderCLIManager.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ class CoderCLIManager(
489489
* version could not be parsed.
490490
*/
491491
fun matchesVersion(rawBuildVersion: String): Boolean? {
492+
if (Files.notExists(localBinaryPath)) return null
492493
val cliVersion = tryVersion() ?: return null
493494
val buildVersion =
494495
try {

0 commit comments

Comments
 (0)