Skip to content

Commit

Permalink
fix: semver.diff prerelease to release recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
dominique-blockchain authored and wraithgar committed Apr 5, 2023
1 parent da08e01 commit 960a0f0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
11 changes: 11 additions & 0 deletions functions/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ const diff = (version1, version2) => {
}
}
}
if (v1['major'] === v2['major'] &&

Check failure on line 20 in functions/diff.js

View workflow job for this annotation

GitHub Actions / Lint

["major"] is better written in dot notation

Check failure on line 20 in functions/diff.js

View workflow job for this annotation

GitHub Actions / Lint

["major"] is better written in dot notation

Check failure on line 20 in functions/diff.js

View workflow job for this annotation

GitHub Actions / Lint

Trailing spaces not allowed
v1['minor'] === v2['minor'] &&

Check failure on line 21 in functions/diff.js

View workflow job for this annotation

GitHub Actions / Lint

["minor"] is better written in dot notation

Check failure on line 21 in functions/diff.js

View workflow job for this annotation

GitHub Actions / Lint

["minor"] is better written in dot notation

Check failure on line 21 in functions/diff.js

View workflow job for this annotation

GitHub Actions / Lint

Trailing spaces not allowed
v1['patch'] === v2['patch'] && !(v1.prerelease.length && v2.prerelease.length)) {

Check failure on line 22 in functions/diff.js

View workflow job for this annotation

GitHub Actions / Lint

["patch"] is better written in dot notation

Check failure on line 22 in functions/diff.js

View workflow job for this annotation

GitHub Actions / Lint

["patch"] is better written in dot notation
const releaseTypes = []
for (const key in v1) {
if (key === 'major' || key === 'minor' || key === 'patch') {
if (v1[key]) releaseTypes.push(key);

Check failure on line 26 in functions/diff.js

View workflow job for this annotation

GitHub Actions / Lint

Expected { after 'if' condition

Check failure on line 26 in functions/diff.js

View workflow job for this annotation

GitHub Actions / Lint

Expected a linebreak before this statement
}
}
return releaseTypes.pop();
}
return defaultResult // may be undefined
}
}
Expand Down
16 changes: 11 additions & 5 deletions test/functions/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ const diff = require('../../functions/diff')
test('diff versions test', (t) => {
// [version1, version2, result]
// diff(version1, version2) -> result
[['1.2.3', '0.2.3', 'major'],
[ ['1.2.3', '0.2.3', 'major'],
['0.2.3', '1.2.3', 'major'],
['1.4.5', '0.2.3', 'major'],
['1.2.3', '2.0.0-pre', 'premajor'],
['2.0.0-pre', '1.2.3', 'premajor'],
['1.2.3', '1.3.3', 'minor'],
['1.0.1', '1.1.0-pre', 'preminor'],
['1.2.3', '1.2.4', 'patch'],
['1.2.3', '1.2.4-pre', 'prepatch'],
['0.0.1', '0.0.1-pre', 'prerelease'],
['0.0.1', '0.0.1-pre-2', 'prerelease'],
['1.1.0', '1.1.0-pre', 'prerelease'],
['0.0.1', '0.0.1-pre', 'patch'],
['0.0.1', '0.0.1-pre-2', 'patch'],
['1.1.0', '1.1.0-pre', 'minor'],
['1.1.0-pre-1', '1.1.0-pre-2', 'prerelease'],
['1.0.0', '1.0.0', null],

['1.0.0', '1.0.0', null]
['1.0.0', '1.0.0', null],
['0.0.2-1', '0.0.2', 'patch'],
['0.1.0-1', '0.1.0', 'minor'],
['1.0.0-1', '1.0.0', 'major']
].forEach((v) => {
const version1 = v[0]

Check failure on line 27 in test/functions/diff.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 10.0.0

Cannot read property '0' of undefined

Check failure on line 27 in test/functions/diff.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 10.x

Cannot read property '0' of undefined

Check failure on line 27 in test/functions/diff.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 12.x

Cannot read property '0' of undefined

Check failure on line 27 in test/functions/diff.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 14.x

Cannot read property '0' of undefined

Check failure on line 27 in test/functions/diff.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 16.x

Cannot read properties of undefined (reading '0')

Check failure on line 27 in test/functions/diff.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.x

Cannot read properties of undefined (reading '0')

Check failure on line 27 in test/functions/diff.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 10.0.0

Cannot read property '0' of undefined

Check failure on line 27 in test/functions/diff.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 10.x

Cannot read property '0' of undefined

Check failure on line 27 in test/functions/diff.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 12.x

Cannot read property '0' of undefined

Check failure on line 27 in test/functions/diff.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 14.x

Cannot read property '0' of undefined

Check failure on line 27 in test/functions/diff.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 16.x

Cannot read properties of undefined (reading '0')

Check failure on line 27 in test/functions/diff.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.x

Cannot read properties of undefined (reading '0')
const version2 = v[1]
Expand Down

0 comments on commit 960a0f0

Please sign in to comment.