Skip to content

Instantly share code, notes, and snippets.

@jfsiii
Created June 29, 2014 21:26
Show Gist options
  • Save jfsiii/ed665a1dec5381407b8e to your computer and use it in GitHub Desktop.
Save jfsiii/ed665a1dec5381407b8e to your computer and use it in GitHub Desktop.
Unexpected behavior from semver for pre-release versions.

From point 9 of the SemVer spec:

A pre-release version indicates that the version is unstable and might not satisfy the intended compatibility requirements as denoted by its associated normal version. Examples: 1.0.0-alpha, 1.0.0-alpha.1, 1.0.0-0.3.7, 1.0.0-x.7.z.92.

However, the package npm uses to process semver values provides no way to specify a range which excludes pre-release versions.

‣ semver --range '~1.2.3' 1.2.3 1.2.4-alpha 1.2.4 1.3.0-alpha 1.3.0 2.0.0-alpha
1.2.3
1.2.4-alpha
1.2.4
‣ semver --range '^1.2.3' 1.2.3 1.2.4-alpha 1.2.4 1.3.0-alpha 1.3.0 2.0.0-alpha
1.2.3
1.2.4-alpha
1.2.4
1.3.0-alpha
1.3.0
‣ semver --range '1.2.x' 1.2.3 1.2.4-alpha 1.2.4 1.3.0-alpha 1.3.0 2.0.0-alpha
1.2.3
1.2.4-alpha
1.2.4    
‣ semver --range '<1.3.0' 1.2.3 1.2.4-alpha 1.2.4 1.3.0-alpha 1.3.0 2.0.0-alpha
1.2.3
1.2.4-alpha
1.2.4
‣ semver --range '<1.3.0-0' 1.2.3 1.2.4-alpha 1.2.4 1.3.0-alpha 1.3.0 2.0.0-alpha
1.2.3
1.2.4-alpha
1.2.4
‣ semver --range '<=1.3.0-0' 1.2.3 1.2.4-alpha 1.2.4 1.3.0-alpha 1.3.0 2.0.0-alpha
1.2.3
1.2.4-alpha
1.2.4
‣ semver --range '<1.3.0' 1.2.3 1.2.4-alpha 1.2.4 1.3.0-alpha 1.3.0 2.0.0-alpha

This is being tracked in #64 and #62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment