Skip to content

Commit

Permalink
Merge pull request #2370 from alphagov/support-no-internet-connection
Browse files Browse the repository at this point in the history
Support no internet connection
  • Loading branch information
BenSurgisonGDS authored Nov 9, 2023
2 parents 9afd727 + ff10068 commit 3a36712
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixes

- [#2370: Support no internet connection](https://github.com/alphagov/govuk-prototype-kit/pull/2370)

## 13.14.0

### New features
Expand Down
8 changes: 6 additions & 2 deletions lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,13 @@ function sortByObjectKey (key) {
}

function hasNewVersion (installedVersion, latestVersion) {
if (!latestVersion) {
return false
}

const matcher = /^(\d+)\.(\d+)\.(\d+)(.+)?/
const [, installedMajor, installedMinor, installedPatch, installedSuffix] = installedVersion.match(matcher)
const [, latestMajor, latestMinor, latestPatch, latestSuffix] = latestVersion.match(matcher)
const [, installedMajor, installedMinor, installedPatch, installedSuffix] = installedVersion?.match(matcher) || []
const [, latestMajor, latestMinor, latestPatch, latestSuffix] = latestVersion?.match(matcher) || []

if (installedMajor < latestMajor) return true
if (installedMajor > latestMajor) return false
Expand Down
1 change: 1 addition & 0 deletions lib/utils/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('sessionFileStoreQuietLogFn', () => {

describe('hasNewVersion', () => {
[
{ installed: '13.1.0', latest: undefined, result: false },
{ installed: '13.1.0', latest: '13.1.0', result: false },
{ installed: '13.1.1', latest: '13.1.0', result: false },
{ installed: '13.2.0', latest: '13.1.0', result: false },
Expand Down

0 comments on commit 3a36712

Please sign in to comment.