Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev mode detection does not always work #46

Closed
steinybot opened this issue Mar 27, 2018 · 4 comments · Fixed by #57
Closed

Dev mode detection does not always work #46

steinybot opened this issue Mar 27, 2018 · 4 comments · Fixed by #57

Comments

@steinybot
Copy link

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.

@kyleu
Copy link

kyleu commented Jun 18, 2018

This bit me too, thanks for the report

@kyleu
Copy link

kyleu commented Jun 19, 2018

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)
    }

@steinybot
Copy link
Author

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("")
  }

@vmunier vmunier mentioned this issue Jun 2, 2020
@vmunier
Copy link
Owner

vmunier commented Jun 2, 2020

sbt-web-scalajs v1.1.0 now relies on scalaJSStage to know whether fastOptJS or fullOptJS should be run.

@vmunier vmunier closed this as completed Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants