live-server icon indicating copy to clipboard operation
live-server copied to clipboard

Override command line arguments

Open mynyml opened this issue 2 years ago • 0 comments

Issue description

Command line arguments cannot be overridden. AFAIK this is expected behaviour among Unix commands (I don't know about non-Unix).

In my particular use case, I have a start script in package.json that specifies a default port, and I sometimes need to override the port per instance. I intuitively expected npm start -- --port=8080 to work but it doesn't.

I looked into the src code and noticed the command line args are consumed starting from the end, which means earlier settings override later ones. I don't know why this decision was taken in the first place so I didn't send in a patch. One obvious fix would be to reverse the loop. Another one would be to specifically not override the port once it's set, though that would break expectations for the other args.

I can submit the patch if this change is desirable.

Software details

  • Command line used for launching live-server: live-server --port=3000 --port=4000
  • OS: linux
  • Node.js version: 16.4.2
  • live-server version: 1.2.1

mynyml avatar Jul 21 '21 14:07 mynyml