Skip to content

Commit

Permalink
Analytics: fix crash when flutter|xcodebuild is not installed (#1839)
Browse files Browse the repository at this point in the history
* Analytics: fix crash when flutter|xcodebuild is not installed

* bump version to v1.37.1
  • Loading branch information
bartekpacia committed Jul 29, 2024
1 parent 546198b commit fa278cf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
GROUP=dev.mobile
VERSION_NAME=1.37.0
VERSION_NAME=1.37.1
POM_DESCRIPTION=Maestro is a server-driven platform-agnostic library that allows to drive tests for both iOS and Android using the same implementation through an intuitive API.
POM_URL=https://github.com/mobile-dev-inc/maestro
POM_SCM_URL=https://github.com/mobile-dev-inc/maestro
Expand All @@ -14,4 +14,4 @@ POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=mobile-dev-inc
POM_DEVELOPER_NAME=mobile.dev inc.
SONATYPE_STAGING_PROFILE=dev.mobile
org.gradle.jvmargs=-Xmx2000m
org.gradle.jvmargs=-Xmx2000m
2 changes: 1 addition & 1 deletion maestro-cli/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CLI_VERSION=1.37.0
CLI_VERSION=1.37.1
14 changes: 10 additions & 4 deletions maestro-cli/src/main/java/maestro/cli/util/EnvUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import maestro.cli.api.CliVersion
import maestro.cli.update.Updates
import maestro.cli.view.red
import java.io.File
import java.io.IOException
import java.nio.file.Path
import java.nio.file.Paths
import java.util.Properties
Expand Down Expand Up @@ -89,10 +90,15 @@ object EnvUtils {
}

fun getFlutterVersionAndChannel(): Pair<String?, String?> {
val stdout = runProcess(
"flutter",
"--no-version-check", "--version", "--machine",
).joinToString(separator = "")
val stdout = try {
runProcess(
"flutter",
"--no-version-check", "--version", "--machine",
).joinToString(separator = "")
} catch (e: IOException) {
// Flutter is probably not installed
return Pair(first = null, second = null)
}

val mapper = jacksonObjectMapper()
val version = runCatching {
Expand Down
8 changes: 7 additions & 1 deletion maestro-cli/src/main/java/maestro/cli/util/IOSEnvUtils.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package maestro.cli.util

import java.io.IOException
import kotlin.io.path.Path

object IOSEnvUtils {
Expand All @@ -23,7 +24,12 @@ object IOSEnvUtils {

val xcodeVersion: String?
get() {
val lines = runProcess("xcodebuild", "-version")
val lines = try {
runProcess("xcodebuild", "-version")
} catch (e: IOException) {
// Xcode toolchain is probably not installed
return null
}

if (lines.size == 2 && lines.first().contains(' ')) {
// Correct xcodebuild invocation is always 2 lines. Example:
Expand Down

0 comments on commit fa278cf

Please sign in to comment.