@magic/semver 0.0.17 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -118,6 +118,10 @@ update dependencies
118
118
  - add typescript
119
119
  - update dependencies
120
120
 
121
- ##### 0.0.18 - unreleased
121
+ ##### 0.0.18
122
+
123
+ - fix handling a v in front of the version, eg v0.0.1
124
+
125
+ ##### 0.0.19 - unreleased
122
126
 
123
127
  ...
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magic/semver",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "author": "Wizards & Witches",
5
5
  "description": "semantic version parsing and serialization.",
6
6
  "license": "AGPL-3.0",
package/src/parse.js CHANGED
@@ -29,7 +29,7 @@ export const parse = v => {
29
29
 
30
30
  /** @type {VersionResult} */
31
31
  const result = {
32
- major: parseInt(major),
32
+ major: parseInt(major.replace('v', '')),
33
33
  minor: parseInt(minor),
34
34
  patch: -1,
35
35
  v,
@@ -48,7 +48,7 @@ export const parse = v => {
48
48
  }
49
49
 
50
50
  if (!is.number(result.major)) {
51
- throw error(`${libName} major was not an Int: ${result.major}`, 'E_MAJOR_TYPE')
51
+ throw error(`${libName} major was not an Int: ${v} ${result.major}`, 'E_MAJOR_TYPE')
52
52
  } else if (!is.number(result.minor)) {
53
53
  throw error(`${libName} minor was not an Int: ${result.minor}`, 'E_MINOR_TYPE')
54
54
  } else if (!is.number(result.patch)) {
package/src/serialize.js CHANGED
@@ -55,5 +55,7 @@ export const serialize = v => {
55
55
  demoString = `-${string}.${version}`
56
56
  }
57
57
 
58
- return `${major}.${minor}.${patch}${demoString}`
58
+ const prefix = is.str(v.v) && v.v.startsWith('v') ? 'v' : ''
59
+
60
+ return `${prefix}${major}.${minor}.${patch}${demoString}`
59
61
  }