@@ -15,6 +15,7 @@ import sbt.Package.ManifestAttributes
1515import com .typesafe .sbteclipse .plugin .EclipsePlugin ._
1616
1717import dotty .tools .sbtplugin .DottyPlugin .autoImport ._
18+ import dotty .tools .sbtplugin .DottyIDEPlugin .{ prepareCommand , runProcess }
1819import dotty .tools .sbtplugin .DottyIDEPlugin .autoImport ._
1920import org .scalajs .sbtplugin .ScalaJSPlugin
2021import org .scalajs .sbtplugin .ScalaJSPlugin .autoImport ._
@@ -766,8 +767,13 @@ object Build {
766767 val mainClass = " dotty.tools.languageserver.Main"
767768 val extensionPath = (baseDirectory in `vscode-dotty`).value.getAbsolutePath
768769
769- val codeArgs = if (inputArgs.isEmpty) List ((baseDirectory.value / " .." ).getAbsolutePath) else inputArgs
770- val allArgs = List (" -client_command" , " code" , s " --extensionDevelopmentPath= $extensionPath" ) ++ codeArgs
770+ val codeArgs =
771+ s " --extensionDevelopmentPath= $extensionPath" +:
772+ (if (inputArgs.isEmpty) List ((baseDirectory.value / " .." ).getAbsolutePath) else inputArgs)
773+
774+ val clientCommand = prepareCommand(codeCommand.value ++ codeArgs)
775+
776+ val allArgs = " -client_command" +: clientCommand
771777
772778 runTask(Runtime , mainClass, allArgs : _* )
773779 }.dependsOn(compile in (`vscode-dotty`, Compile )).evaluated
@@ -893,7 +899,7 @@ object Build {
893899
894900
895901 sbtPlugin := true ,
896- version := " 0.1.2 " ,
902+ version := " 0.1.3 " ,
897903 ScriptedPlugin .scriptedSettings,
898904 ScriptedPlugin .sbtTestDirectory := baseDirectory.value / " sbt-test" ,
899905 ScriptedPlugin .scriptedBufferLog := false ,
@@ -924,76 +930,36 @@ object Build {
924930 compile in Compile := {
925931 val coursier = baseDirectory.value / " out/coursier"
926932 val packageJson = baseDirectory.value / " package.json"
927- if (! coursier.exists || packageJson.lastModified > coursier.lastModified) {
928- val exitCode = new java.lang.ProcessBuilder (" npm" , " run" , " update-all" )
929- .directory(baseDirectory.value)
930- .inheritIO()
931- .start()
932- .waitFor()
933- if (exitCode != 0 )
934- throw new MessageOnlyException (" 'npm run update-all' in vscode-dotty failed" )
935- }
933+ if (! coursier.exists || packageJson.lastModified > coursier.lastModified)
934+ runProcess(Seq (" npm" , " run" , " update-all" ), wait = true , directory = baseDirectory.value)
936935 val tsc = baseDirectory.value / " node_modules" / " .bin" / " tsc"
937- val exitCodeTsc = new java.lang.ProcessBuilder (tsc.getAbsolutePath, " --pretty" , " --project" , baseDirectory.value.getAbsolutePath)
938- .inheritIO()
939- .start()
940- .waitFor()
941- if (exitCodeTsc != 0 )
942- throw new MessageOnlyException (" tsc in vscode-dotty failed" )
936+ runProcess(Seq (tsc.getAbsolutePath, " --pretty" , " --project" , baseDirectory.value.getAbsolutePath), wait = true )
943937
944938 // Currently, vscode-dotty depends on daltonjorge.scala for syntax highlighting,
945939 // this is not automatically installed when starting the extension in development mode
946940 // (--extensionDevelopmentPath=...)
947- val exitCodeInstall = new java.lang.ProcessBuilder (" code" , " --install-extension" , " daltonjorge.scala" )
948- .inheritIO()
949- .start()
950- .waitFor()
951- if (exitCodeInstall != 0 )
952- throw new MessageOnlyException (" Installing dependency daltonjorge.scala failed" )
941+ runProcess(codeCommand.value ++ Seq (" --install-extension" , " daltonjorge.scala" ), wait = true )
953942
954943 sbt.inc.Analysis .Empty
955944 },
956945 sbt.Keys .`package`:= {
957- val exitCode = new java.lang.ProcessBuilder (" vsce" , " package" )
958- .directory(baseDirectory.value)
959- .inheritIO()
960- .start()
961- .waitFor()
962- if (exitCode != 0 )
963- throw new MessageOnlyException (" vsce package failed" )
946+ runProcess(Seq (" vsce" , " package" ), wait = true , directory = baseDirectory.value)
964947
965948 baseDirectory.value / s " dotty- ${version.value}.vsix "
966949 },
967950 unpublish := {
968- val exitCode = new java.lang.ProcessBuilder (" vsce" , " unpublish" )
969- .directory(baseDirectory.value)
970- .inheritIO()
971- .start()
972- .waitFor()
973- if (exitCode != 0 )
974- throw new MessageOnlyException (" vsce unpublish failed" )
951+ runProcess(Seq (" vsce" , " unpublish" ), wait = true , directory = baseDirectory.value)
975952 },
976953 publish := {
977- val exitCode = new java.lang.ProcessBuilder (" vsce" , " publish" )
978- .directory(baseDirectory.value)
979- .inheritIO()
980- .start()
981- .waitFor()
982- if (exitCode != 0 )
983- throw new MessageOnlyException (" vsce publish failed" )
954+ runProcess(Seq (" vsce" , " publish" ), wait = true , directory = baseDirectory.value)
984955 },
985956 run := Def .inputTask {
986957 val inputArgs = spaceDelimited(" <arg>" ).parsed
987958 val codeArgs = if (inputArgs.isEmpty) List ((baseDirectory.value / " .." ).getAbsolutePath) else inputArgs
988959 val extensionPath = baseDirectory.value.getAbsolutePath
989- val processArgs = List (" code" , s " --extensionDevelopmentPath= ${extensionPath}" ) ++ codeArgs
990-
991- val exitCode = new java.lang.ProcessBuilder (processArgs : _* )
992- .inheritIO()
993- .start()
994- .waitFor()
995- if (exitCode != 0 )
996- throw new MessageOnlyException (" Running Visual Studio Code failed" )
960+ val processArgs = List (s " --extensionDevelopmentPath= ${extensionPath}" ) ++ codeArgs
961+
962+ runProcess(codeCommand.value ++ processArgs, wait = true )
997963 }.dependsOn(compile in Compile ).evaluated
998964 )
999965
0 commit comments