Merge pull request #7085 from dos65/bspconfig_windows_path_fix

This commit is contained in:
eugene yokota 2022-12-06 21:57:57 -05:00 committed by GitHub
commit 973cd63e0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

1
.gitignore vendored
View File

@ -13,3 +13,4 @@ npm-debug.log
.bsp/
metals.sbt
launcher-package/citest/freshly-baked
.vscode

View File

@ -63,8 +63,10 @@ object BuildServerConnection {
// For those who use an old sbt script, the -Dsbt.script is not set
// As a fallback we try to find the sbt script in $PATH
val fileName = if (Properties.isWin) "sbt.bat" else "sbt"
val envPath = sys.env.getOrElse("PATH", "")
val allPaths = envPath.split(File.pathSeparator).map(Paths.get(_))
val envPath = sys.env.collectFirst {
case (k, v) if k.toUpperCase() == "PATH" => v
}
val allPaths = envPath.map(_.split(File.pathSeparator).map(Paths.get(_))).getOrElse(Array.empty)
allPaths
.map(_.resolve(fileName))
.find(file => Files.exists(file) && Files.isExecutable(file))