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

cli options don't override the default options in .ncurc.js #1355

Open
3 tasks done
its-dibo opened this issue Nov 20, 2023 · 6 comments
Open
3 tasks done

cli options don't override the default options in .ncurc.js #1355

its-dibo opened this issue Nov 20, 2023 · 6 comments

Comments

@its-dibo
Copy link

  • I have searched for similar issues
  • I am using the latest version of npm-check-updates
  • I am using node >= 14.14

when you set default options in .ncurc.js, these options don't be overridden by those that provided via cli

for example if you have a .ncurc.js like this

module.exports = {
  target: "minor"
  ...
}

then you triggered the following command

ncu --target=latest

then, the minor target is used

@raineorshine
Copy link
Owner

The syntax is actually ncu --target latest.

@its-dibo
Copy link
Author

nice. it should also support this syntax because it is widly used and more readable.
typically tools like commander, yargs and other cli parsers can read and parse this syntax

@raineorshine
Copy link
Owner

raineorshine commented Nov 21, 2023

It uses commander, so I'm not sure why the equals delimiter is not working actually. I will look into that.

An option and its option-argument can be separated by a space, or combined into the same argument. The option-argument can follow the short option directly or follow an = for a long option.

serve -p 80
serve -p80
serve --port 80
serve --port=80

@raineorshine
Copy link
Owner

raineorshine commented Nov 21, 2023

Okay, so that wasn't the problem at all. I'm just not use to the = delimiter, but it works as expected with npm-check-updates.

I set up the scenario you described, and am unable to reproduce the issue. The CLI option correctly overrides the .ncurc.js option:

raine[1355]% cat package.json                                                                                             ✓
{
  "dependencies": {
    "ncu-test-v2": "^1.0.0",
    "ncu-test-tag": "^1.0.0"
  }
}

raine[1355]% cat .ncurc.js                                                                                                ✓
module.exports = {
  target: "minor"
}

raine[1355]% ncu
Using config file /Users/raine/projects/ncu-issues/1355/.ncurc.js
Checking /Users/raine/projects/ncu-issues/1355/package.json
[====================] 2/2 100%

 ncu-test-tag  ^1.0.0  →  ^1.1.0

Run ncu -u to upgrade package.json

raine[1355]% ncu --target=latest                                                                                          ✓
Using config file /Users/raine/projects/ncu-issues/1355/.ncurc.js
Checking /Users/raine/projects/ncu-issues/1355/package.json
[====================] 2/2 100%

 ncu-test-tag  ^1.0.0  →  ^1.1.0
 ncu-test-v2   ^1.0.0  →  ^2.0.0

Run ncu --target=latest -u to upgrade package.json

If you are not seeing the expected upgrades, it is probably due to something else. Feel free to post a package.json and .ncurc.js that reproduce the issue and I'd be happy to investigate further.

@its-dibo
Copy link
Author

ok, let me reproduce the issue again and give you a feedback

@raineorshine
Copy link
Owner

Let me know if you can reproduce the issue, otherwise I'll close this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants