Skip to content

Commit

Permalink
README
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Jul 28, 2023
1 parent 86ce798 commit 1b0bbfa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,18 +424,18 @@ Only available in .ncurc.js or when importing npm-check-updates as a module.

```js
/** Filter out non-major version updates.
@param {string} packageName The name of the dependency.
@param {string} currentVersion Current version declaration (may be range).
@param {SemVer[]} currentVersionSemver Current version declaration in semantic versioning format (may be range).
@param {string} upgradedVersion Upgraded version.
@param {SemVer} upgradedVersionSemver Upgraded version in semantic versioning format.
@returns {boolean} Return true if the upgrade should be kept, otherwise it will be ignored.
@param {string} packageName The name of the dependency.
@param {string} current Current version declaration (may be a range).
@param {SemVer[]} currentSemver Current version declaration in semantic versioning format (may be a range).
@param {string} upgraded Upgraded version.
@param {SemVer} upgradedSemver Upgraded version in semantic versioning format.
@returns {boolean} Return true if the upgrade should be kept, otherwise it will be ignored.
*/
filterResults: (packageName, { currentVersion, currentVersionSemver, upgradedVersion, upgradedVersionSemver }) => {
const currentMajorVersion = currentVersionSemver?.[0]?.major
const upgradedMajorVersion = upgradedVersionSemver?.major
if (currentMajorVersion && upgradedMajorVersion) {
return currentMajorVersion < upgradedMajorVersion
filterResults: (packageName, { current, currentSemver, upgraded, upgradedSemver }) => {
const currentMajor = parseInt(currentSemver?.[0]?.major, 10)
const upgradedMajor = parseInt(upgradedSemver?.major, 10)
if (currentMajor && upgradedMajor) {
return currentMajor < upgradedMajor
}
return true
}
Expand Down
24 changes: 11 additions & 13 deletions src/cli-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,20 @@ Only available in .ncurc.js or when importing npm-check-updates as a module.
${codeBlock(
`${chalk.gray(`/** Filter out non-major version updates.
@param {string} packageName The name of the dependency.
@param {string} currentVersion Current version declaration (may be range).
@param {SemVer[]} currentVersionSemver Current version declaration in semantic versioning format (may be range).
@param {string} upgradedVersion Upgraded version.
@param {SemVer} upgradedVersionSemver Upgraded version in semantic versioning format.
@returns {boolean} Return true if the upgrade should be kept, otherwise it will be ignored.
@param {string} packageName The name of the dependency.
@param {string} current Current version declaration (may be a range).
@param {SemVer[]} currentSemver Current version declaration in semantic versioning format (may be a range).
@param {string} upgraded Upgraded version.
@param {SemVer} upgradedSemver Upgraded version in semantic versioning format.
@returns {boolean} Return true if the upgrade should be kept, otherwise it will be ignored.
*/`)}
${chalk.cyan(
'filterResults',
)}: (packageName, { currentVersion, currentVersionSemver, upgradedVersion, upgradedVersionSemver }) ${chalk.cyan(
${chalk.cyan('filterResults')}: (packageName, { current, currentSemver, upgraded, upgradedSemver }) ${chalk.cyan(
'=>',
)} {
const currentMajorVersion = currentVersionSemver?.[${chalk.blue('0')}]?.major
const upgradedMajorVersion = upgradedVersionSemver?.major
${chalk.red('if')} (currentMajorVersion ${chalk.red('&&')} upgradedMajorVersion) {
${chalk.red('return')} currentMajorVersion ${chalk.red('<')} upgradedMajorVersion
const currentMajor = parseInt(currentSemver?.[${chalk.blue('0')}]?.major, 10)
const upgradedMajor = parseInt(upgradedSemver?.major, 10)
${chalk.red('if')} (currentMajor ${chalk.red('&&')} upgradedMajor) {
${chalk.red('return')} currentMajor ${chalk.red('<')} upgradedMajor
}
${chalk.red('return')} ${chalk.blue('true')}
}`,
Expand Down

0 comments on commit 1b0bbfa

Please sign in to comment.