@@ -15,6 +15,7 @@ import sbt.Package.ManifestAttributes
15
15
import com .typesafe .sbteclipse .plugin .EclipsePlugin ._
16
16
17
17
import dotty .tools .sbtplugin .DottyPlugin .autoImport ._
18
+ import dotty .tools .sbtplugin .DottyIDEPlugin .{ prepareCommand , runProcess }
18
19
import dotty .tools .sbtplugin .DottyIDEPlugin .autoImport ._
19
20
import org .scalajs .sbtplugin .ScalaJSPlugin
20
21
import org .scalajs .sbtplugin .ScalaJSPlugin .autoImport ._
@@ -766,8 +767,13 @@ object Build {
766
767
val mainClass = " dotty.tools.languageserver.Main"
767
768
val extensionPath = (baseDirectory in `vscode-dotty`).value.getAbsolutePath
768
769
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
771
777
772
778
runTask(Runtime , mainClass, allArgs : _* )
773
779
}.dependsOn(compile in (`vscode-dotty`, Compile )).evaluated
@@ -893,7 +899,7 @@ object Build {
893
899
894
900
895
901
sbtPlugin := true ,
896
- version := " 0.1.2 " ,
902
+ version := " 0.1.3 " ,
897
903
ScriptedPlugin .scriptedSettings,
898
904
ScriptedPlugin .sbtTestDirectory := baseDirectory.value / " sbt-test" ,
899
905
ScriptedPlugin .scriptedBufferLog := false ,
@@ -924,76 +930,36 @@ object Build {
924
930
compile in Compile := {
925
931
val coursier = baseDirectory.value / " out/coursier"
926
932
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)
936
935
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 )
943
937
944
938
// Currently, vscode-dotty depends on daltonjorge.scala for syntax highlighting,
945
939
// this is not automatically installed when starting the extension in development mode
946
940
// (--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 )
953
942
954
943
sbt.inc.Analysis .Empty
955
944
},
956
945
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)
964
947
965
948
baseDirectory.value / s " dotty- ${version.value}.vsix "
966
949
},
967
950
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)
975
952
},
976
953
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)
984
955
},
985
956
run := Def .inputTask {
986
957
val inputArgs = spaceDelimited(" <arg>" ).parsed
987
958
val codeArgs = if (inputArgs.isEmpty) List ((baseDirectory.value / " .." ).getAbsolutePath) else inputArgs
988
959
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 )
997
963
}.dependsOn(compile in Compile ).evaluated
998
964
)
999
965
0 commit comments