Custom CLI arguments failing in version 3.0.5
See original GitHub issueDo you want to request a feature or report a bug?
Reporting a bug
What is the current behaviour?
When upgrading an application to 3.0.5, custom CLI arguments no longer work and throw an error when attempting to run via “npm run dev”. This behavior works in 3.0.3, so something with the upgrade removed the ability to do this. This seems to be a breaking change, as projects using custom CLI commands will no longer work post-upgrade.
Custom CLI arguments are insanely useful for providing global variables and customizing behavior based on things like instance or client - and the breaking change caused by the minor version upgrade should be prevented in any case, as applications using custom CLI arguments no longer function when upgraded from 3.0.3 to 3.0.5.
Thank you much for the help!
If the current behaviour is a bug, please provide the steps to reproduce.
- In a preact application with preact-cli@3.0.3, add a custom CLI argument to the “dev” script in the package.json file. This can be a fresh project made from “preact create”
"dev": "preact watch --port 9090 --CUSTOM my-value",
-
Run the script via “npm run dev”. This should work fine and the application should start.
-
Upgrade to preact-cli@3.0.5
-
Run the script again via “npm run dev” and note that the script fails with the following error.
× ERROR Invalid argument CUSTOM passed to watch. Please refer to 'preact watch --help' for full list of options.
What is the expected behaviour?
Custom CLI arguments should be accepted, or some other way to provide custom parameters should be provided.
If this is a feature request, what is motivation or use case for changing the behaviour?
Please mention other relevant information.
Please paste the results of preact info
here.
System: OS: Windows 10 10.0.18363 CPU: (12) x64 Intel® Core™ i7-9750H CPU @ 2.60GHz Binaries: Node: 12.16.1 - C:\Program Files\nodejs\node.EXE npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD Browsers: Chrome: 87.0.4280.141 Edge: Spartan (44.18362.449.0) npmPackages: preact: ^10.3.2 => 10.5.9 preact-cli: ^3.0.5 => 3.0.5 preact-render-to-string: ^5.1.4 => 5.1.12 preact-router: ^3.2.1 => 3.2.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10 (6 by maintainers)
Top GitHub Comments
@Dmurl5 Looks like custom flags will be a no-go. Environment variables are the way to go for that.
We can leave this open for now, wait for feedback.
You don’t have to use
cross-env
, but it seems like Windows is quite touchy about white space which seemed like a hassle. Here’s SO thread with a few solutions, not sure which would work for you: https://stackoverflow.com/questions/9249830/how-can-i-set-node-env-production-on-windowsIf you are an organization which could be cross platform,
cross-env
is the simplest solution usually.