Skip to content

Conversation

@SebastianSedzik
Copy link
Contributor

@SebastianSedzik SebastianSedzik commented Oct 13, 2025

Description

This PR adds support for passing a predicate function to the cooldown option, providing more granular (per-package) control over cooldown behavior — for example, setting different cooldown durations or disabling cooldowns for specific packages (see example below).

Docs

You can also provide a custom function in your .ncurc.js file or when importing npm-check-updates as a module.

⚠️ The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions.

/** Set cooldown to 3 days but skip it for `@my-company` packages.
  @param packageName     The name of the dependency.
  @returns               Cooldown days restriction for given package.
*/
cooldown: packageName => packageName.startsWith('@my-company') ? 0 : 3

Resolves: #1562

Copy link
Owner

@raineorshine raineorshine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This looks great.

it('throws error for negative cooldown', () => {
expect(
ncu({
packageFile: 'test/test-data/cooldown/package.json',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right that the packageFile was removed. Can you explain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raineorshine Yes, this is intentional. I removed the test/test-data/cooldown/package.json file in an earlier PR but missed the references in these two tests. Since both are designed to fail during options type checking, NCU never reaches the code that loads or checks the package path. The issue only became visible when I temporarily broke the options checker during development. Keeping the packageFile option in these tests could be misleading, as the referenced file no longer exists.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see! Thanks for clarifying!

it('throws error for negative cooldown', () => {
expect(
ncu({
packageFile: 'test/test-data/cooldown/package.json',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see! Thanks for clarifying!

@raineorshine raineorshine merged commit 3499a2f into raineorshine:main Oct 13, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature enhancement: allow excluding packages from cooldown period

2 participants