You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -460,6 +460,18 @@ Note for latest/tag targets:
460
460
461
461
> :warning: For packages that update frequently (e.g. daily releases), using a long cooldown period (7+ days) with the default `--target latest` or `--target @tag` may prevent all updates since new versions will be published before older ones meet the cooldown requirement. Please consider this when setting your cooldown period.
462
462
463
+
You can also provide a custom function in your .ncurc.js file or when importing npm-check-updates as a module.
464
+
465
+
> :warning: 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.
466
+
467
+
```js
468
+
/** Set cooldown to 3 days but skip it for `@my-company` packages.
469
+
@parampackageName The name of the dependency.
470
+
@returns Cooldown days restriction for given package (when null cooldown will be skipped for given package).
Copy file name to clipboardExpand all lines: src/cli-options.ts
+13-1Lines changed: 13 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -599,6 +599,18 @@ ${chalk.bold('Note for latest/tag targets')}:
599
599
600
600
> :warning: For packages that update frequently (e.g. daily releases), using a long cooldown period (7+ days) with the default \`--target latest\` or \`--target @tag\` may prevent all updates since new versions will be published before older ones meet the cooldown requirement. Please consider this when setting your cooldown period.
601
601
602
+
You can also provide a custom function in your .ncurc.js file or when importing npm-check-updates as a module.
603
+
604
+
> :warning: 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.
605
+
606
+
${codeBlock(
607
+
`${chalk.gray(`/** Set cooldown to 3 days but skip it for \`@my-company\` packages.
608
+
@param packageName The name of the dependency.
609
+
@returns Cooldown days restriction for given package (when null cooldown will be skipped for given package).
'Sets a minimum age (in days) for package versions to be considered for upgrade, reducing the risk of installing newly published, potentially compromised packages.',
/** Returns a composite predicate that filters out deprecated, prerelease, and node engine incompatibilies from version objects returns by packument. */
Copy file name to clipboardExpand all lines: src/types/RunOptions.json
+10-2Lines changed: 10 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -181,8 +181,16 @@
181
181
"type": "string"
182
182
},
183
183
"cooldown": {
184
-
"description": "Sets a minimum age (in days) for package versions to be considered for upgrade, reducing the risk of installing newly published, potentially compromised packages. Run \"ncu --help --cooldown\" for details.",
185
-
"type": "number"
184
+
"anyOf": [
185
+
{
186
+
"description": "A function that can be provided to the --cooldown option for custom cooldown predicate.",
187
+
"type": "object"
188
+
},
189
+
{
190
+
"type": "number"
191
+
}
192
+
],
193
+
"description": "Sets a minimum age (in days) for package versions to be considered for upgrade, reducing the risk of installing newly published, potentially compromised packages. Run \"ncu --help --cooldown\" for details."
186
194
},
187
195
"cwd": {
188
196
"description": "Working directory in which npm will be executed.",
Copy file name to clipboardExpand all lines: src/types/RunOptions.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
/** This file is generated automatically from the options specified in /src/cli-options.ts. Do not edit manually. Run "npm run build" or "npm run build:options" to build. */
/** Sets a minimum age (in days) for package versions to be considered for upgrade, reducing the risk of installing newly published, potentially compromised packages. Run "ncu --help --cooldown" for details. */
44
-
cooldown?: number
45
+
cooldown?: number|CooldownFunction
45
46
46
47
/** Working directory in which npm will be executed. */
it('should apply custom cooldown when predicate returns a number',async()=>{
515
+
// Given: default cooldown set to 10, test-package and test-package-2 - both installed in version 1.0.0, and both has the latest version 1.1.0 released 5 days ago (within cooldown)
516
+
constcooldown=10
517
+
constpackageData: PackageFile={
518
+
dependencies: {
519
+
'test-package': '1.0.0',
520
+
'test-package-2': '1.0.0',
521
+
},
522
+
}
523
+
conststub=stubVersions({
524
+
'test-package': createMockVersion({
525
+
name: 'test-package',
526
+
versions: {
527
+
'1.1.0': newDate(NOW-5*DAY).toISOString(),
528
+
},
529
+
distTags: {
530
+
latest: '1.1.0',
531
+
},
532
+
}),
533
+
'test-package-2': createMockVersion({
534
+
name: 'test-package-2',
535
+
versions: {
536
+
'1.1.0': newDate(NOW-5*DAY).toISOString(),
537
+
},
538
+
distTags: {
539
+
latest: '1.1.0',
540
+
},
541
+
}),
542
+
})
543
+
544
+
// When: cooldown predicate returns 5 for test-package (skipping cooldown), and 10 for the rest packages
// Then: test-package is upgraded to version 1.1.0 (as cooldown for this package was set to 5), but test-package-2 is not upgraded (as rest of the packages use default cooldown of 10)
0 commit comments