mirror of https://github.com/sbt/sbt.git
Don't fail loading the build if npm is missing or we are on Windows
This commit is contained in:
parent
7e1a904b95
commit
f761dab63e
23
build.sbt
23
build.sbt
|
|
@ -446,6 +446,17 @@ lazy val sbtProj = (project in file("sbt"))
|
||||||
)
|
)
|
||||||
.configure(addSbtCompilerBridge)
|
.configure(addSbtCompilerBridge)
|
||||||
|
|
||||||
|
def runNpm(command: String, base: File, log: sbt.internal.util.ManagedLogger) = {
|
||||||
|
val npm = if (sbt.internal.util.Util.isWindows) "npm.cmd" else "npm"
|
||||||
|
import scala.sys.process._
|
||||||
|
try {
|
||||||
|
val exitCode = Process(s"$npm $command", Option(base)) ! log
|
||||||
|
if (exitCode != 0) throw new Exception("Process returned exit code: " + exitCode)
|
||||||
|
} catch {
|
||||||
|
case e: java.io.IOException => log.warn("failed to run npm " + e.getMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lazy val vscodePlugin = (project in file("vscode-sbt-scala"))
|
lazy val vscodePlugin = (project in file("vscode-sbt-scala"))
|
||||||
.settings(
|
.settings(
|
||||||
crossPaths := false,
|
crossPaths := false,
|
||||||
|
|
@ -453,12 +464,8 @@ lazy val vscodePlugin = (project in file("vscode-sbt-scala"))
|
||||||
skip in publish := true,
|
skip in publish := true,
|
||||||
compile in Compile := {
|
compile in Compile := {
|
||||||
val u = update.value
|
val u = update.value
|
||||||
val log = streams.value.log
|
runNpm("run compile", baseDirectory.value, streams.value.log)
|
||||||
import sbt.internal.inc.Analysis
|
sbt.internal.inc.Analysis.empty
|
||||||
import scala.sys.process._
|
|
||||||
val exitCode = Process(s"npm run compile", Option(baseDirectory.value)) ! log
|
|
||||||
if (exitCode != 0) throw new Exception("Process returned exit code: " + exitCode)
|
|
||||||
Analysis.empty
|
|
||||||
},
|
},
|
||||||
update := {
|
update := {
|
||||||
val old = update.value
|
val old = update.value
|
||||||
|
|
@ -467,9 +474,7 @@ lazy val vscodePlugin = (project in file("vscode-sbt-scala"))
|
||||||
val log = streams.value.log
|
val log = streams.value.log
|
||||||
if (t.exists) ()
|
if (t.exists) ()
|
||||||
else {
|
else {
|
||||||
import scala.sys.process._
|
runNpm("install", base, log)
|
||||||
val exitCode = Process("npm install", Option(base)) ! log
|
|
||||||
if (exitCode != 0) throw new Exception("Process returned exit code: " + exitCode)
|
|
||||||
IO.touch(t)
|
IO.touch(t)
|
||||||
}
|
}
|
||||||
old
|
old
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue