GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: Warn when defaulting to --inc=patch in CLI by pjohnmeyer · Pull Request #859 · npm/node-semver

Conversation

@pjohnmeyer

@pjohnmeyer pjohnmeyer commented May 7, 2026

Copy link
Copy Markdown
Contributor

Adds a warning log message to the CLI when the --increment option is provided with an invalid increment type. This provides adequate feedback to the user about what is happening, and prepares them for a future where this may no longer be allowed.

In #108 (comment), @mklement0 points out (correctly, IMO):

Quietly accepting invalid input is problematic.

As @lukekarrys points out in his reply, however, he considers erroring here to be a breaking change. I would tend to agree as this behavior has become part of the contract between the CLI user and the CLI.

The issue is being tracked for the next major version of the CLI, so I offer up that we can safely add the warning indicating that a bad value has been provided, simultaneously preserving the contract, and preparing users for the possibility of a future change. As console.warn does not output to stdout, existing redirection and/or piping of output should survive this change, thus it will not be breaking. Examples:

% ./bin/semver.js --inc patchouli 3.2.1 > ./new-version.redirected
Invalid value for --inc; defaulting to 'patch'. This may become a failure in future major versions.
% cat ./new-version.redirected
3.2.2

% ./bin/semver.js --inc patchouli 3.2.1 | tee ./new-version.teed
Invalid value for --inc; defaulting to 'patch'. This may become a failure in future major versions.
3.2.2
% cat ./new-version.teed 
3.2.2

The only breakage, then, would occur if we consider stderr (or in this case lack thereof) output to also be part of the CLI contract. Example:

% ./bin/semver.js --inc patchouli 3.2.1 &> ./new-version.err    
% cat ./new-version.err 
Invalid value for --inc; defaulting to 'patch'. This may become a failure in future major versions.
3.2.2

In this case the warning and the new version are both output to ./new-version.err, and any processing of that output expecting only 3.2.2 might fail.

Alternative

We could, instead, add a flag to the CLI to opt-in to new behavior re: the --inc flag. This could be done in three different ways I can immediately think of:

  • --increment-strict: an alternate flag used instead of --increment that enforces the validity of the argument; downside is that we would then want to remove this in the next release, creating another breaking change
  • --future: a generic flag that hides all breaking "next version" (currently 8) functionality behind a feature flag, used in combination with --increment to enforce the validity of the argument
  • --verbose: adds the additional "warning" logging added in this PR, with the opportunity for more usage elsewhere

I think the approach in this PR is the simplest and requires the least change in the future, but --future and --verbose open up other options going forward.

References

Relates to #108

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mklement0 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@pjohnmeyer
fix: Warn when defaulting to --inc=patch in CLI
6ad73df
@pjohnmeyer
pjohnmeyer requested a review from a team as a code owner May 7, 2026 13:53
pjohnmeyer
pjohnmeyer commented May 7, 2026
View reviewed changes
Comment thread bin/semver.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

owlstronaut
owlstronaut approved these changes May 7, 2026
View reviewed changes
@owlstronaut
owlstronaut merged commit 3905343 into npm:main May 7, 2026
25 of 29 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Mar 20, 2026
chore: release 7.8.0 #847
Merged
owlstronaut pushed a commit that referenced this pull request May 8, 2026
@github-actions
chore: release 7.8.0 (#847)
efa4be6
🤖 I have created a release *beep* *boop*
---


## [7.8.0](v7.7.4...v7.8.0)
(2026-05-08)
### Features
*
[`0d0a0a2`](0d0a0a2)
[#855](#855) Add `truncate`
function (#855) (@pjohnmeyer, @owlstronaut)
### Bug Fixes
*
[`3905343`](3905343)
[#859](#859) Warn when defaulting
to --inc=patch in CLI (@pjohnmeyer)
### Documentation
*
[`c368af6`](c368af6)
[#853](#853) fix typos in
documentation (#853) (@ankitkumar572005)
*
[`37776c3`](37776c3)
[#846](#846) fix BNF grammar to
distinguish prerelease from build identifiers (#846) (@abhu85, @claude)
### Chores
*
[`9542e09`](9542e09)
[#860](#860) template-oss-apply
(@owlstronaut)
*
[`937bc2c`](937bc2c)
[#860](#860)
`[email protected]` (@owlstronaut)
*
[`6946fef`](6946fef)
[#852](#852) bump
@npmcli/template-oss from 4.29.0 to 4.30.0 (#852) (@dependabot[bot],
@npm-cli-bot)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions Bot mentioned this pull request May 9, 2026
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#75
Closed
5 tasks
@pjohnmeyer pjohnmeyer mentioned this pull request May 10, 2026
CLI accepts invalid increment specifiers with -i/--increment and treats them as 'patch' #108
Open
This was referenced May 10, 2026
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#79
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#83
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#87
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#91
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#95
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#100
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#106
Closed
This was referenced May 17, 2026
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#112
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#118
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#124
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#131
Closed
deps: semver 7.7.4 → 7.8.0 suj1e/larkcc#137
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#143
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#149
Closed
This was referenced May 24, 2026
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#155
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#161
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#167
Open
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#174
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#180
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#186
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#193
Closed
This was referenced May 31, 2026
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#200
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#208
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#216
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#224
Closed
deps: semver 7.7.4 → 7.8.1 suj1e/larkcc#232
Closed
deps: semver 7.7.4 → 7.8.2 suj1e/larkcc#240
Closed
deps: semver 7.7.4 → 7.8.2 suj1e/larkcc#248
Closed
This was referenced Jun 7, 2026
deps: semver 7.7.4 → 7.8.2 suj1e/larkcc#256
Closed
deps: semver 7.7.4 → 7.8.2 suj1e/larkcc#264
Closed
deps: semver 7.7.4 → 7.8.3 suj1e/larkcc#273
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#282
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#291
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#300
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#309
Closed
This was referenced Jun 14, 2026
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#318
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#327
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#336
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#345
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#354
Closed
deps: semver 7.7.4 → 7.8.4 suj1e/larkcc#363
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@owlstronaut owlstronaut owlstronaut approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@pjohnmeyer @owlstronaut
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.