Skip to content

Commit 1fcf824

Browse files
committed
Build.scala: Use newly-added runProcess where possible
1 parent adeeb42 commit 1fcf824

File tree

2 files changed

+8
-37
lines changed

2 files changed

+8
-37
lines changed

project/Build.scala

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -930,22 +930,10 @@ object Build {
930930
compile in Compile := {
931931
val coursier = baseDirectory.value / "out/coursier"
932932
val packageJson = baseDirectory.value / "package.json"
933-
if (!coursier.exists || packageJson.lastModified > coursier.lastModified) {
934-
val exitCode = new java.lang.ProcessBuilder("npm", "run", "update-all")
935-
.directory(baseDirectory.value)
936-
.inheritIO()
937-
.start()
938-
.waitFor()
939-
if (exitCode != 0)
940-
throw new MessageOnlyException("'npm run update-all' in vscode-dotty failed")
941-
}
933+
if (!coursier.exists || packageJson.lastModified > coursier.lastModified)
934+
runProcess(Seq("npm", "run", "update-all"), wait = true, directory = baseDirectory.value)
942935
val tsc = baseDirectory.value / "node_modules" / ".bin" / "tsc"
943-
val exitCodeTsc = new java.lang.ProcessBuilder(tsc.getAbsolutePath, "--pretty", "--project", baseDirectory.value.getAbsolutePath)
944-
.inheritIO()
945-
.start()
946-
.waitFor()
947-
if (exitCodeTsc != 0)
948-
throw new MessageOnlyException("tsc in vscode-dotty failed")
936+
runProcess(Seq(tsc.getAbsolutePath, "--pretty", "--project", baseDirectory.value.getAbsolutePath), wait = true)
949937

950938
// Currently, vscode-dotty depends on daltonjorge.scala for syntax highlighting,
951939
// this is not automatically installed when starting the extension in development mode
@@ -955,33 +943,15 @@ object Build {
955943
sbt.inc.Analysis.Empty
956944
},
957945
sbt.Keys.`package`:= {
958-
val exitCode = new java.lang.ProcessBuilder("vsce", "package")
959-
.directory(baseDirectory.value)
960-
.inheritIO()
961-
.start()
962-
.waitFor()
963-
if (exitCode != 0)
964-
throw new MessageOnlyException("vsce package failed")
946+
runProcess(Seq("vsce", "package"), wait = true, directory = baseDirectory.value)
965947

966948
baseDirectory.value / s"dotty-${version.value}.vsix"
967949
},
968950
unpublish := {
969-
val exitCode = new java.lang.ProcessBuilder("vsce", "unpublish")
970-
.directory(baseDirectory.value)
971-
.inheritIO()
972-
.start()
973-
.waitFor()
974-
if (exitCode != 0)
975-
throw new MessageOnlyException("vsce unpublish failed")
951+
runProcess(Seq("vsce", "unpublish"), wait = true, directory = baseDirectory.value)
976952
},
977953
publish := {
978-
val exitCode = new java.lang.ProcessBuilder("vsce", "publish")
979-
.directory(baseDirectory.value)
980-
.inheritIO()
981-
.start()
982-
.waitFor()
983-
if (exitCode != 0)
984-
throw new MessageOnlyException("vsce publish failed")
954+
runProcess(Seq("vsce", "publish"), wait = true, directory = baseDirectory.value)
985955
},
986956
run := Def.inputTask {
987957
val inputArgs = spaceDelimited("<arg>").parsed

sbt-dotty/src/dotty/tools/sbtplugin/DottyIDEPlugin.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ object DottyIDEPlugin extends AutoPlugin {
131131
val exitCode = pb.start().waitFor()
132132
if (exitCode != 0) {
133133
val cmdString = cmd.mkString(" ")
134-
throw new MessageOnlyException("""Running command "${cmdString}" failed.""")
134+
val description = if (directory != null) s""" in directory "$directory"""" else ""
135+
throw new MessageOnlyException(s"""Running command "${cmdString}"${description} failed.""")
135136
}
136137
}
137138
else

0 commit comments

Comments
 (0)