Last change
on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
634 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | const parse = require('./parse')
|
---|
| 2 | const eq = require('./eq')
|
---|
| 3 |
|
---|
| 4 | const diff = (version1, version2) => {
|
---|
| 5 | if (eq(version1, version2)) {
|
---|
| 6 | return null
|
---|
| 7 | } else {
|
---|
| 8 | const v1 = parse(version1)
|
---|
| 9 | const v2 = parse(version2)
|
---|
| 10 | const hasPre = v1.prerelease.length || v2.prerelease.length
|
---|
| 11 | const prefix = hasPre ? 'pre' : ''
|
---|
| 12 | const defaultResult = hasPre ? 'prerelease' : ''
|
---|
| 13 | for (const key in v1) {
|
---|
| 14 | if (key === 'major' || key === 'minor' || key === 'patch') {
|
---|
| 15 | if (v1[key] !== v2[key]) {
|
---|
| 16 | return prefix + key
|
---|
| 17 | }
|
---|
| 18 | }
|
---|
| 19 | }
|
---|
| 20 | return defaultResult // may be undefined
|
---|
| 21 | }
|
---|
| 22 | }
|
---|
| 23 | module.exports = diff
|
---|
Note:
See
TracBrowser
for help on using the repository browser.