Skip to content

Commit 4724e0d

Browse files
authored
Skip reading ide-options-v2.json if doesn't exist to avoid throwing an error (#2333)
1 parent 654950a commit 4724e0d

File tree

1 file changed

+7
-4
lines changed
  • modules/cli/src/main/scala/scala/cli/commands/bsp

1 file changed

+7
-4
lines changed

modules/cli/src/main/scala/scala/cli/commands/bsp/Bsp.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ object Bsp extends ScalaCommand[BspOptions] {
2121
override def hidden = true
2222
override def scalaSpecificationLevel = SpecificationLevel.IMPLEMENTATION
2323
private def latestSharedOptions(options: BspOptions): SharedOptions =
24-
options.jsonOptions.map { optionsPath =>
25-
val content = os.read.bytes(os.Path(optionsPath, os.pwd))
26-
readFromArray(content)(SharedOptions.jsonCodec)
27-
}.getOrElse(options.shared)
24+
options.jsonOptions
25+
.map(path => os.Path(path, os.pwd))
26+
.filter(path => os.exists(path) && os.isFile(path))
27+
.map { optionsPath =>
28+
val content = os.read.bytes(os.Path(optionsPath, os.pwd))
29+
readFromArray(content)(SharedOptions.jsonCodec)
30+
}.getOrElse(options.shared)
2831
override def sharedOptions(options: BspOptions): Option[SharedOptions] =
2932
Option(latestSharedOptions(options))
3033

0 commit comments

Comments
 (0)