Skip to content

mildlyfunctional/vp-migrate-repro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

vp migrate bug reproduction

Reproduces a false-positive in vp migrate where husky v9 is rejected when its version is declared as "latest" in package.json.

The bug

vp migrate reads the husky version from package.json devDependencies and uses semver.coerce() to parse it. When the value is a dist-tag like "latest", semver.coerce("latest") returns null, which falls back to "0.0.0" and incorrectly satisfies < 9.0.0.

// migrator.js
return semver.satisfies(semver.coerce(huskyVersion) ?? '0.0.0', '<9.0.0');
//                                                     ^^^^^^^
//                      "latest" coerces to null, falls back to 0.0.0

The same false-positive applies to any non-semver version string: "next", "canary", "*", etc.

Steps to reproduce

  1. Clone this repo
  2. Run vp migrate
  3. See: Detected husky <9.0.0 — please upgrade to husky v9+ first, then re-run migration.

Expected behavior

vp migrate should proceed. When the declared version is a dist-tag or otherwise uncoerceable, the check should either resolve the actual installed version from node_modules or treat the version as indeterminate and skip the block.

Workaround

Pin the version explicitly in package.json:

"husky": "^9.1.7"

semver.coerce("^9.1.7") returns 9.1.7, which correctly fails the < 9.0.0 check.

About

vp migrate bug reproduction

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors