Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: web-ext automatically checks for updates (#676)
- Loading branch information
1 parent
dbdf9e2
commit 31d2e46
Showing
5 changed files
with
120 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* @flow */ | ||
import defaultUpdateNotifier from 'update-notifier'; | ||
|
||
type checkForUpdatesParams = {| | ||
version: string, | ||
updateNotifier?: typeof defaultUpdateNotifier, | ||
|}; | ||
|
||
export function checkForUpdates( | ||
{ | ||
version, | ||
updateNotifier = defaultUpdateNotifier, | ||
}: checkForUpdatesParams | ||
) { | ||
const pkg = {name: 'web-ext', version}; | ||
|
||
updateNotifier({ | ||
pkg, | ||
updateCheckInterval: 1000 * 60 * 60 * 24 * 3, // 3 days, | ||
}).notify(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* @flow */ | ||
import {it, describe} from 'mocha'; | ||
import {assert} from 'chai'; | ||
import sinon from 'sinon'; | ||
|
||
import {checkForUpdates} from '../../../src/util/updates'; | ||
|
||
describe('util/updates', () => { | ||
describe('checkForUpdates()', () => { | ||
it('calls the notifier with the correct parameters', () => { | ||
const updateNotifierStub = sinon.spy(() => { | ||
return { | ||
notify: sinon.spy(), | ||
}; | ||
}); | ||
|
||
checkForUpdates({ | ||
version: '1.0.0', | ||
updateNotifier: updateNotifierStub, | ||
}); | ||
assert.equal(updateNotifierStub.called, true); | ||
assert.equal(updateNotifierStub.firstCall.args[0].pkg.name, 'web-ext'); | ||
assert.equal(updateNotifierStub.firstCall.args[0].pkg.version, '1.0.0'); | ||
assert.isNumber(updateNotifierStub.firstCall.args[0].updateCheckInterval); | ||
assert.equal(updateNotifierStub.firstCall.args[0].updateCheckInterval, | ||
1000 * 60 * 60 * 24 * 3); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters