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

elm make separator -- is not seen as a command prompt argument in powershell unless it is quoted #223

Open
olenitsj opened this issue Mar 22, 2020 · 1 comment

Comments

@olenitsj
Copy link

olenitsj commented Mar 22, 2020

node --version
v12.16.1.

elm --version
0.19.1

elm-live --version
4.0.2

When running: PS C:\Users\Igor\Documents\sources\repos\com.olenitsj> .\node_modules\.bin\elm-live.ps1 src/Main.elm -e node_modules/.bin/elm -- --output=main.js
on Windows 10, power-shell.

Results in:

----------------------
|| ERROR IN COMMAND ||
----------------------
Usage: <elm-main> [options] [--] [elm make options]

-- Output In Wrong Location -----------------

You have used the elm make flag --output in the wrong location. As seen in the usage example about, all elm make flags must be added to your command after the -- separator.

image

The work around:

Quoting the --
e.g. PS C:\Users\Igor\Documents\sources\repos\com.olenitsj> .\node_modules\.bin\elm-live.ps1 src/Main.elm -e node_modules/.bin/elm '--' --output=main.js

Proposed solution:

Update example code to use '--', unless this is breaking some other behavior.

Or fix this part of the code:

In node_modules/elm-live/bin/elm-live.js:

const errorReducer = isHot => ([past, flags], arg) => {
  const isOutput = arg.includes('--output')
  if (!past && isOutput) {
    flags.wrongLocation = true
  }

  if (isHot && isOutput) {
    const target = arg.split('=')[1]
    const outputType = mime.getType(target)
    if (outputType !== 'application/javascript') {
      flags.needsJs = true
    }
  }

  return [past || arg === '--', flags]
}

The arg === '--' check is never true as the -- is never received as a parameter in program.rawArgs

Some related material:

https://stackoverflow.com/questions/43046885/what-does-do-when-running-an-npm-command
https://stackoverflow.com/questions/15780174/powershell-command-line-parameters-and
https://stackoverflow.com/questions/12197823/powershell-why-do-i-need-to-escape-a-double-dash-parameter-in-args

@olenitsj olenitsj changed the title elm make seperator -- is not seen as a commandpormpt argumnt in powershell unless. elm make separator -- is not seen as a command prompt argument in powershell Mar 22, 2020
@olenitsj olenitsj changed the title elm make separator -- is not seen as a command prompt argument in powershell elm make separator -- is not seen as a command prompt argument in powershell unless quoted Mar 22, 2020
@olenitsj olenitsj changed the title elm make separator -- is not seen as a command prompt argument in powershell unless quoted elm make separator -- is not seen as a command prompt argument in powershell unless it is quoted Mar 22, 2020
@wking-io
Copy link
Owner

Thanks for finding this bug! I will have to take a look. Maybe we can remove the need for it altogether 👌

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

No branches or pull requests

2 participants