File tree 1 file changed +11
-6
lines changed
modules/options/src/main/scala/scala/build/options
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import scala.build.Positioned
9
9
import scala .build .errors .{BuildException , MalformedInputError }
10
10
import scala .io .Codec
11
11
import scala .jdk .CollectionConverters .*
12
- import scala .util .Using
12
+ import scala .util .{ Success , Try , Using }
13
13
14
14
sealed abstract class ComputeVersion extends Product with Serializable {
15
15
def get (workspace : os.Path ): Either [BuildException , String ]
@@ -19,11 +19,16 @@ object ComputeVersion {
19
19
20
20
final case class Command (command : Seq [String ]) extends ComputeVersion {
21
21
def get (workspace : os.Path ): Either [BuildException , String ] = {
22
- val res = os.proc(command).call(stdin = os.Inherit , cwd = workspace, check = false )
23
- if (res.exitCode == 0 )
24
- Right (res.out.trim(Codec .default))
25
- else
26
- Left (new Command .ComputeVersionCommandError (command, res.exitCode))
22
+ val maybeRes = Try (os.proc(command).call(stdin = os.Inherit , cwd = workspace, check = false ))
23
+ maybeRes match {
24
+ case Success (res) if res.exitCode == 0 =>
25
+ Right (res.out.trim(Codec .default))
26
+ case _ =>
27
+ Left (new Command .ComputeVersionCommandError (
28
+ command,
29
+ maybeRes.map(_.exitCode).getOrElse(1 )
30
+ ))
31
+ }
27
32
}
28
33
}
29
34
You can’t perform that action at this time.
0 commit comments