From baa1fd4e4a8e386268d6f05ad73374cde5c5ce60 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Fri, 27 Sep 2024 08:36:09 +0200 Subject: [PATCH] refactor(common-utils)!: Clarify the use of `resolveExecutable()` Make more clear from the name that the function does not only work on Windows. Signed-off-by: Sebastian Schuberth --- utils/common/src/main/kotlin/Os.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/common/src/main/kotlin/Os.kt b/utils/common/src/main/kotlin/Os.kt index 5be96ddff5f18..f6a3aa599c492 100644 --- a/utils/common/src/main/kotlin/Os.kt +++ b/utils/common/src/main/kotlin/Os.kt @@ -108,7 +108,7 @@ object Os { paths.firstNotNullOfOrNull { path -> val expandedPath = path.expandVariable(referencePattern) - resolveWindowsExecutable(File(expandedPath, executable)) + resolveExecutable(File(expandedPath, executable)) } } else { val referencePattern = Regex("\\$\\{?(\\w+)}?") @@ -121,9 +121,9 @@ object Os { } /** - * Resolve the Windows [executable] to its full name including the optional extension. + * Resolve the [executable] to its full name including any optional Windows extension. */ - fun resolveWindowsExecutable(executable: File): File? { + fun resolveExecutable(executable: File): File? { val extensions = env["PATHEXT"]?.splitToSequence(File.pathSeparatorChar).orEmpty() return extensions.map { File(executable.path + it.lowercase()) }.find { it.isFile } ?: executable.takeIf { it.isFile }