Dev mode detection does not always work
steinybot opened this issue · 4 comments
With sbt 1.1.1 I was running a Play project using the task server / run
. The executedCommandKey
task will stop parsing the task when it encounters whitespace and so in this case executedCommandKey
is "server"
and not "run"
. The consequence is that isDevMode
will be false
instead of true
.
This bit me too, thanks for the report
To work around the issue, I changed isDevMode
's definition to be more permissive. Probably too permissive (note the endsWith
).
(isDevMode in scalaJSPipeline) := {
val cmd = CrossSbtUtils.executedCommandKey.value.trim
(devCommands in scalaJSPipeline).value.exists(cmd.endsWith)
}
I think that is still going to have the same problem since it is executedCommandKey
with the issue.
What we want to be able to do is use sbt.internal.Act#aggregatedKeyParser
and then parse the state and see what keys we got. Being internal that probably isn't going to work.
We could still do it with a similar approach if we remove whitespace around the /
:
lazy val executedCommandKey = Def.task {
state.value.history.currentOption.flatMap {
_.commandLine
.replaceAll("\\s+/", "/")
.replaceAll("/\\s+", "/")
.takeWhile(c => !c.isWhitespace)
.split(Array('/', ':')).lastOption
}.getOrElse("")
}
sbt-web-scalajs v1.1.0
now relies on scalaJSStage
to know whether fastOptJS
or fullOptJS
should be run.