Skip to content

[BUG] Parsing of flags with boolean & string values is incorrect. #6313

@ianlewis

Description

@ianlewis

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

The npm fund command has a --browser flag which can be null (not provided), a boolean value, or a string.

However there are a number of things wrong with it.

  1. npm fund --browser=open should attempt to use the "open" command to open a browser. However the argument resolves to the value true and the system default is used.
  2. npm fund --browser --help should parse the --help flag but doesn't because it's treated as an argument to the --browser flag.

The end result is only boolean values can actually be input as all string values resolve to the boolean value true.

Expected Behavior

  1. npm fund --browser=open should attempt to use the appropriate method to open the browser.
  2. npm fund --browser --help should parse any flags after the --browser flag as a flag rather than an argument to the --browser flag.

Steps To Reproduce

  1. Run npm fund --browser=open on a Linux system.
  2. The system default xdg-open is used to open the browser.

Environment

  • npm: npm HEAD (60460ed)
  • Node.js: v16.17.0
  • OS Name: Debian Linux
  • npm config: None
; "user" config from /usr/local/google/home/ianlewis/.npmrc

//registry.npmjs.org/:_authToken = (protected) 

; "project" config from /usr/local/google/home/ianlewis/opt/node-v16.17.0-linux-x64/bin/node_modules/npm/.npmrc

package-lock = true 

; node bin location = /usr/local/google/home/ianlewis/opt/node-v16.17.0-linux-x64/bin/node
; node version = v16.17.0
; npm local prefix = /usr/local/google/home/ianlewis/opt/node-v16.17.0-linux-x64/bin/node_modules/npm
; npm version = 8.15.0
; cwd = /usr/local/google/home/ianlewis/opt/node-v16.17.0-linux-x64/bin/node_modules/npm
; HOME = /usr/local/google/home/ianlewis
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 9.xwork is associated with a specific npm 9 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions