Skip to content

Commit 9223fca

Browse files
committed
Run all commands properly on Windows, not just code
1 parent 1fcf824 commit 9223fca

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

project/Build.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import sbt.Package.ManifestAttributes
1515
import com.typesafe.sbteclipse.plugin.EclipsePlugin._
1616

1717
import dotty.tools.sbtplugin.DottyPlugin.autoImport._
18-
import dotty.tools.sbtplugin.DottyIDEPlugin.runProcess
18+
import dotty.tools.sbtplugin.DottyIDEPlugin.{ prepareCommand, runProcess }
1919
import dotty.tools.sbtplugin.DottyIDEPlugin.autoImport._
2020
import org.scalajs.sbtplugin.ScalaJSPlugin
2121
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
@@ -771,7 +771,7 @@ object Build {
771771
s"--extensionDevelopmentPath=$extensionPath" +:
772772
(if (inputArgs.isEmpty) List((baseDirectory.value / "..").getAbsolutePath) else inputArgs)
773773

774-
val clientCommand = codeCommand.value ++ codeArgs
774+
val clientCommand = prepareCommand(codeCommand.value ++ codeArgs)
775775

776776
val allArgs = "-client_command" +: clientCommand
777777

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,17 @@ object DottyIDEPlugin extends AutoPlugin {
124124
runTask(joinedTask, state)
125125
}
126126

127+
/** Prepare command to be passed to ProcessBuilder */
128+
def prepareCommand(cmd: Seq[String]): Seq[String] =
129+
if (isWin) Seq("cmd.exe", "/C") ++ cmd
130+
else cmd
131+
132+
/** Run `cmd`.
133+
* @param wait If true, wait for `cmd` to return and throw an exception if the exit code is non-zero.
134+
* @param directory If not null, run `cmd` in this directory.
135+
*/
127136
def runProcess(cmd: Seq[String], wait: Boolean = false, directory: File = null): Unit = {
128-
val pb0 = new ProcessBuilder(cmd: _*).inheritIO()
137+
val pb0 = new ProcessBuilder(prepareCommand(cmd): _*).inheritIO()
129138
val pb = if (directory != null) pb0.directory(directory) else pb0
130139
if (wait) {
131140
val exitCode = pb.start().waitFor()
@@ -221,9 +230,7 @@ object DottyIDEPlugin extends AutoPlugin {
221230
commands ++= Seq(configureIDE, compileForIDE),
222231

223232
codeCommand := {
224-
if (isWin)
225-
Seq("cmd.exe", "/C", "code", "-n")
226-
else if (isMac)
233+
if (isMac)
227234
Seq("open", "-a", "Visual Studio Code", "--args", "-n")
228235
else
229236
Seq("code", "-n")

0 commit comments

Comments
 (0)