Skip to content

Commit

Permalink
README
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Mar 14, 2024
1 parent ffeeee4 commit c09c380
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,9 @@ Usage:
ncu --filter [p]
ncu -f [p]

Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.
Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. Only included packages will be checked with `--peer`.

`--filter` runs _before_ new versions are fetched, in contrast to `--filterResults` which runs _after_.

The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line.

Expand All @@ -467,7 +469,7 @@ filterFunction: (name, semver) => {

Filters out upgrades based on a user provided function.

`filterResults` runs _after_ new versions are fetched, in contrast to `filter` and `filterVersion`, which run _before_. This allows you to filter out upgrades with `filterResults` based on how the version has changed (e.g. a major version change).
`filterResults` runs _after_ new versions are fetched, in contrast to `filter`, `reject`, `filterVersion`, and `rejectVersion`, which run _before_. This allows you to filter out upgrades with `filterResults` based on how the version has changed (e.g. a major version change).

Only available in .ncurc.js or when importing npm-check-updates as a module.

Expand Down Expand Up @@ -675,7 +677,9 @@ Usage:
ncu --reject [p]
ncu -x [p]
The inverse of `--filter`. Exclude package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.
The inverse of `--filter`. Exclude package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. This will also exclude them from the `--peer` check.
`--reject` runs _before_ new versions are fetched, in contrast to `--filterResults` which runs _after_.
The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line.
Expand Down Expand Up @@ -711,7 +715,7 @@ The predicate function is only available in .ncurc.js or when importing npm-chec
(See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
@returns True if the package should be excluded, false if it should be included.
*/
filterVersionFunction: (name, semver) => {
rejectVersionFunction: (name, semver) => {
if (name.startsWith('@myorg/') && parseInt(semver[0]?.major) > 5) {
return true
}
Expand Down
25 changes: 21 additions & 4 deletions src/cli-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ const extendedHelpFilterResults: ExtendedHelp = ({ markdown }) => {
${codeInline('filterResults')} runs _after_ new versions are fetched, in contrast to ${codeInline(
'filter',
)} and ${codeInline('filterVersion')}, which run _before_. This allows you to filter out upgrades with ${codeInline(
)}, ${codeInline('reject')}, ${codeInline('filterVersion')}, and ${codeInline(
'rejectVersion',
)}, which run _before_. This allows you to filter out upgrades with ${codeInline(
'filterResults',
)} based on how the version has changed (e.g. a major version change).
Expand Down Expand Up @@ -201,7 +203,16 @@ const extendedHelpInstall: ExtendedHelp = ({ markdown }) => {

/** Extended help for the --filter option. */
const extendedHelpFilterFunction: ExtendedHelp = ({ markdown }) => {
return `Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.
/** If markdown, surround inline code with backticks. */
const codeInline = (code: string) => (markdown ? `\`${code}\`` : code)

return `Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. Only included packages will be checked with ${codeInline(
'--peer',
)}.
${codeInline('--filter')} runs _before_ new versions are fetched, in contrast to ${codeInline(
'--filterResults',
)} which runs _after_.
The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line.
Expand Down Expand Up @@ -258,7 +269,13 @@ const extendedHelpRejectFunction: ExtendedHelp = ({ markdown }) => {

return `The inverse of ${codeInline(
'--filter',
)}. Exclude package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.
)}. Exclude package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. This will also exclude them from the ${codeInline(
'--peer',
)} check.
${codeInline('--reject')} runs _before_ new versions are fetched, in contrast to ${codeInline(
'--filterResults',
)} which runs _after_.
The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line.
Expand Down Expand Up @@ -299,7 +316,7 @@ ${codeBlock(
(See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
@returns True if the package should be excluded, false if it should be included.
*/`)}
${chalk.green('filterVersionFunction')}: (name, semver) ${chalk.cyan('=>')} {
${chalk.green('rejectVersionFunction')}: (name, semver) ${chalk.cyan('=>')} {
${chalk.red('if')} (name.startsWith(${chalk.yellow(`'@myorg/'`)}) ${chalk.red(
'&&',
)} parseInt(semver[0]?.major) ${chalk.cyan('>')} ${chalk.cyan(`5`)}) {
Expand Down

0 comments on commit c09c380

Please sign in to comment.