elm-live
elm-live copied to clipboard
elm make separator -- is not seen as a command prompt argument in powershell unless it is quoted
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.
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
Thanks for finding this bug! I will have to take a look. Maybe we can remove the need for it altogether 👌