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

Passing empty string for parameter --reject makes ncu to detect empty package.json #1201

Closed
3 tasks done
jonArzelus opened this issue Oct 7, 2022 · 2 comments
Closed
3 tasks done
Labels

Comments

@jonArzelus
Copy link

I have detected some problem with the current way ncu handles the --reject parameter when an empty string ("") is provided for this parameter; Currently it checks the dependencies on the home directory of the current user (or somewhere else that is not the current directory). (even if you configure --cwd correctly), I have checked the --loglevel silly for correct detection of the package.json intended to upgrade to be correct.

Steps to reproduce:

Create a new project (I am using yarn package manager but npm also will work) and add a outdated dependency for later checking with ncu:

cd ~/project
yarn init
yarn add inherits@1.0.0
ncu --cwd ~/project --reject "" --loglevel silly

Current Behavior

It outputs the following:

Running in local mode
Finding package file data
Checking /home/user/Documents/project/package.json

Options:
{
  args: [],
  cache: false,
  cacheExpiration: 10,
  cacheFile: '~/.ncu-cache.json',
  cacher: undefined,
  cli: true,
  concurrency: 8,
  cwd: '/home/user/project',
  deep: false,
  dep: 'prod,dev,bundle,optional',
  errorLevel: 1,
  format: [],
  json: false,
  loglevel: 'silly',
  minimal: false,
  packageManager: 'npm',
  prefix: undefined,
  reject: [ '', '' ],
  retry: 3,
  target: 'latest',
  workspace: []
}

Current versions:
{}

Fetching latest versions

Fetched versions:
{}

Upgraded versions:
{}

No dependencies.

Expected Behavior

It should output the following:

Running in local mode
Finding package file data
Checking /home/user/Documents/project/package.json

Options:
{
  args: [],
  cache: false,
  cacheExpiration: 10,
  cacheFile: '~/.ncu-cache.json',
  cacher: undefined,
  cli: true,
  concurrency: 8,
  cwd: '/home/user/project',
  deep: false,
  dep: 'prod,dev,bundle,optional',
  errorLevel: 1,
  format: [],
  json: false,
  loglevel: 'silly',
  minimal: false,
  packageManager: 'npm',
  prefix: undefined,
  reject: [],
  retry: 3,
  target: 'latest',
  workspace: []
}

Current versions:
{ inherits: '1.0.0' }

Fetching latest versions
[====================] 1/1 100%

Fetched versions:
{ inherits: '2.0.4' }

Upgraded versions:
{ inherits: '2.0.4' }

 inherits  1.0.0  →  2.0.4

Run ncu --cwd /home/user/project --loglevel silly -u to upgrade package.json

OR, at least, it should warn you about the empty --reject parameter and work this way (or warn about this behaviour somewhere in the docs, idk). One thing is for sure, the current behaviour looks faulty to me.

Thanks!


  • node version: v16.13.0
  • npm version: 8.19.2
  • npm-check-updates version: 16.3.8
  • output from npm -g ls --depth=0:
├── corepack@0.10.0
├── eslint-config-react-app@7.0.1
├── eslint@8.20.0
├── npm-check-updates@16.3.8
├── npm@8.19.2
├── pm2@5.1.2
├── prettier@2.6.2
├── serve@14.0.1
├── source-map-explorer@2.5.2
└── yarn@1.22.19
  • I have searched for similar issues
  • I am using the latest version of npm-check-updates
  • I am using node >= 14
@jonArzelus jonArzelus reopened this Oct 7, 2022
raineorshine added a commit that referenced this issue Oct 8, 2022
Although it depends on access to an internal commander variable, this is cleaner than checking every option for duplicates as implemented in b1adf7e.
@raineorshine
Copy link
Owner

Hi, thanks for reporting.

This turned out to be caused by a bug in which options got duplicated. For some reason the duplicated empty reject excluded all dependencies. My previous solution didn't cover all options. Now I have generalized it and added the necessary tests.

Fixed and published in v16.3.9

@jonArzelus
Copy link
Author

Nice! Looking forward for it, thanks!

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

No branches or pull requests

2 participants