Skip to content

Commit

Permalink
refactor(common-utils)!: Clarify the use of resolveExecutable()
Browse files Browse the repository at this point in the history
Make more clear from the name that the function does not only work on
Windows.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Sep 27, 2024
1 parent f9a91f9 commit baa1fd4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions utils/common/src/main/kotlin/Os.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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+)}?")
Expand All @@ -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 }
Expand Down

0 comments on commit baa1fd4

Please sign in to comment.