Skip to content

Commit

Permalink
Add custom target function instructions to cli-options.
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Feb 28, 2022
1 parent 648f3fc commit 769bace
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/cli-options.ts
Expand Up @@ -39,7 +39,24 @@ by each project's maintainers. Default.`])
other version numbers that are higher. Includes prereleases.`])
table.push(['patch', `Upgrade to the highest patch version without bumping the minor or major versions.`])

return `Set the target version that is upgraded to (default: "latest").\n\n${table.toString()}`
return `Set the target version that is upgraded to (default: "latest").
${table.toString()}
You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates:
${chalk.gray(`/** Custom target.
@param dependencyName The name of the dependency.
@param parsedVersion A parsed Semver object from semver-utils.
(See https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
@returns One of the valid target values (specified in the table above).
*/`)}
${chalk.cyan('target')}: (dependencyName, [{ semver, version, operator, major, minor, patch, release, build }]) ${chalk.cyan('=>')} {
${chalk.red('if')} (major ${chalk.red('===')} ${chalk.blue('0')}) ${chalk.red('return')} ${chalk.yellow('\'minor\'')}
${chalk.red('return')} ${chalk.yellow('\'latest\'')}
}
`
}

// store CLI options separately from bin file so that they can be used to build type definitions
Expand Down Expand Up @@ -307,6 +324,7 @@ As a comparison: without using the --peer option, ncu will suggest the latest ve
arg: 'value',
description: 'Target version to upgrade to: latest, newest, greatest, minor, patch. Run "ncu --help --target" for details.` (default: "latest")',
help: getHelpTargetTable(),
type: 'string | TargetFunction',
},
{
long: 'timeout',
Expand Down

0 comments on commit 769bace

Please sign in to comment.