From f3d017f03d3be0cd84ac3fe8604bbbdac1a3690a Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Thu, 15 Dec 2016 23:28:37 +0530 Subject: [PATCH 01/15] feat: web-ext checks for updates and alerts the user to update --- src/program.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/program.js b/src/program.js index 18fcdfefdc..47adce59f5 100644 --- a/src/program.js +++ b/src/program.js @@ -1,6 +1,7 @@ /* @flow */ import path from 'path'; import {readFileSync} from 'fs'; +import updateNotifier from 'update-notifier'; import git from 'git-rev-sync'; import yargs from 'yargs'; @@ -113,6 +114,16 @@ export class Program { throw new UsageError(`Unknown command: ${cmd}`); } await runCommand(argv); + + let pkg = { + name: 'web-ext', + version: defaultVersionGetter(absolutePackageDir), + }; + + updateNotifier({ + pkg, + updateCheckInterval: 1000 * 60 * 60 * 24 * 7, // 1 week + }).notify(); } catch (error) { const prefix = cmd ? `${cmd}: ` : ''; if (!(error instanceof UsageError) || argv.verbose) { From 40f2e649632ff00809ee69382c26278d79a8f6bb Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Thu, 15 Dec 2016 23:42:31 +0530 Subject: [PATCH 02/15] fix: saved update-notifier to package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 1dbeb0db6a..c1103175b7 100644 --- a/package.json +++ b/package.json @@ -57,12 +57,13 @@ "minimatch": "3.0.3", "mz": "2.6.0", "node-firefox-connect": "1.2.0", - "regenerator-runtime": "0.10.1", "parse-json": "2.2.0", + "regenerator-runtime": "0.10.0", "sign-addon": "0.2.0", "source-map-support": "0.4.7", "stream-to-promise": "2.2.0", "tmp": "0.0.30", + "update-notifier": "1.0.3", "watchpack": "1.1.0", "yargs": "6.5.0", "zip-dir": "1.0.2" From 95e292150efd7fb39cb7afdfc4bad17ada81b552 Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Fri, 16 Dec 2016 01:19:26 +0530 Subject: [PATCH 03/15] test: [wip] check for automatic updates and alert the users --- src/program.js | 34 +++++++++++++++++++++++++++------- tests/unit/test.program.js | 15 ++++++++++++++- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/program.js b/src/program.js index 47adce59f5..40dcc753da 100644 --- a/src/program.js +++ b/src/program.js @@ -113,17 +113,14 @@ export class Program { if (!runCommand) { throw new UsageError(`Unknown command: ${cmd}`); } - await runCommand(argv); - let pkg = { + checkForAutomaticUpdates ({ name: 'web-ext', version: defaultVersionGetter(absolutePackageDir), - }; + updateCheckInterval: 1000 * 60 * 60 * 24 * 7, + }); + await runCommand(argv); - updateNotifier({ - pkg, - updateCheckInterval: 1000 * 60 * 60 * 24 * 7, // 1 week - }).notify(); } catch (error) { const prefix = cmd ? `${cmd}: ` : ''; if (!(error instanceof UsageError) || argv.verbose) { @@ -144,6 +141,29 @@ export class Program { } } +type checkForAutomaticUpdatesParams = { + name: string, + version: string, + updateCheckInterval: number, +}; + +export function checkForAutomaticUpdates({ + name, + version, + updateCheckInterval, +}: checkForAutomaticUpdatesParams +) { + let pkg = { + name: name, + version: version, + }; + + updateNotifier({ + pkg, + updateCheckInterval: updateCheckInterval, + }).notify(); +} + // A global variable generated by DefinePlugin, generated in webpack.config.js declare var WEBEXT_BUILD_ENV: string; diff --git a/tests/unit/test.program.js b/tests/unit/test.program.js index a728944caf..4bd121c9b6 100644 --- a/tests/unit/test.program.js +++ b/tests/unit/test.program.js @@ -7,7 +7,12 @@ import {fs} from 'mz'; import sinon, {spy} from 'sinon'; import {assert} from 'chai'; -import {defaultVersionGetter, main, Program} from '../../src/program'; +import { + defaultVersionGetter, + main, + Program, + checkForAutomaticUpdates, +} from '../../src/program'; import commands from '../../src/cmd'; import {onlyInstancesOf, UsageError} from '../../src/errors'; import {fake, makeSureItFails} from './helpers'; @@ -241,6 +246,14 @@ describe('program.Program', () => { }); }); + it('checks for automatic updates', () => { + checkForAutomaticUpdates ({ + name: 'web-ext', + version: '1.0.0', + updateCheckInterval: 0, + }); + }); + }); From 63801031d963c16f4433ccbbec21b73ca6164c90 Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Fri, 16 Dec 2016 13:30:44 +0530 Subject: [PATCH 04/15] feat: checks for updates automatically and alerts user - moved it to a new file as a utility function --- src/program.js | 36 ++++++++++-------------------------- src/util/updates.js | 25 +++++++++++++++++++++++++ tests/unit/test.program.js | 10 ---------- 3 files changed, 35 insertions(+), 36 deletions(-) create mode 100644 src/util/updates.js diff --git a/src/program.js b/src/program.js index 40dcc753da..6a3a15eb05 100644 --- a/src/program.js +++ b/src/program.js @@ -1,7 +1,6 @@ /* @flow */ import path from 'path'; import {readFileSync} from 'fs'; -import updateNotifier from 'update-notifier'; import git from 'git-rev-sync'; import yargs from 'yargs'; @@ -10,6 +9,7 @@ import defaultCommands from './cmd'; import {UsageError} from './errors'; import {createLogger, consoleStream as defaultLogStream} from './util/logger'; import {coerceCLICustomPreference} from './firefox/preferences'; +import {checkForAutomaticUpdates} from './util/updates'; const log = createLogger(__filename); const envPrefix = 'WEB_EXT'; @@ -22,10 +22,15 @@ export class Program { yargs: any; commands: { [key: string]: Function }; shouldExitProgram: boolean; + checkForUpdates: typeof checkForAutomaticUpdates; constructor( argv: ?Array, - {absolutePackageDir = process.cwd()}: {absolutePackageDir?: string} = {} + { + absolutePackageDir = process.cwd(), + }: { + absolutePackageDir?: string, + } = {} ) { // This allows us to override the process argv which is useful for // testing. @@ -38,6 +43,7 @@ export class Program { // config (See web-ext#469 for rationale). const yargsInstance = yargs(argv, absolutePackageDir); + this.checkForUpdates = checkForAutomaticUpdates; this.shouldExitProgram = true; this.yargs = yargsInstance; this.yargs.strict(); @@ -114,7 +120,7 @@ export class Program { throw new UsageError(`Unknown command: ${cmd}`); } - checkForAutomaticUpdates ({ + this.checkForUpdates ({ name: 'web-ext', version: defaultVersionGetter(absolutePackageDir), updateCheckInterval: 1000 * 60 * 60 * 24 * 7, @@ -141,29 +147,6 @@ export class Program { } } -type checkForAutomaticUpdatesParams = { - name: string, - version: string, - updateCheckInterval: number, -}; - -export function checkForAutomaticUpdates({ - name, - version, - updateCheckInterval, -}: checkForAutomaticUpdatesParams -) { - let pkg = { - name: name, - version: version, - }; - - updateNotifier({ - pkg, - updateCheckInterval: updateCheckInterval, - }).notify(); -} - // A global variable generated by DefinePlugin, generated in webpack.config.js declare var WEBEXT_BUILD_ENV: string; @@ -195,6 +178,7 @@ export function main( runOptions = {}, }: Object = {} ): Promise { + const program = new Program(argv, {absolutePackageDir}); // yargs uses magic camel case expansion to expose options on the // final argv object. For example, the 'artifacts-dir' option is alternatively diff --git a/src/util/updates.js b/src/util/updates.js new file mode 100644 index 0000000000..48cd0e0352 --- /dev/null +++ b/src/util/updates.js @@ -0,0 +1,25 @@ +/* @flow */ +import updateNotifier from 'update-notifier'; + +type checkForAutomaticUpdatesParams = { + name: string, + version: string, + updateCheckInterval: number, +}; + +export function checkForAutomaticUpdates({ + name, + version, + updateCheckInterval, +}: checkForAutomaticUpdatesParams +) { + let pkg = { + name: name, + version: version, + }; + + updateNotifier({ + pkg, + updateCheckInterval: updateCheckInterval, + }).notify(); +} \ No newline at end of file diff --git a/tests/unit/test.program.js b/tests/unit/test.program.js index 4bd121c9b6..1a27a27350 100644 --- a/tests/unit/test.program.js +++ b/tests/unit/test.program.js @@ -11,7 +11,6 @@ import { defaultVersionGetter, main, Program, - checkForAutomaticUpdates, } from '../../src/program'; import commands from '../../src/cmd'; import {onlyInstancesOf, UsageError} from '../../src/errors'; @@ -245,15 +244,6 @@ describe('program.Program', () => { assert.match(error.message, /Unknown argument: nope/); }); }); - - it('checks for automatic updates', () => { - checkForAutomaticUpdates ({ - name: 'web-ext', - version: '1.0.0', - updateCheckInterval: 0, - }); - }); - }); From 6f22604431224728f30c0ce35487849a3053da19 Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Mon, 19 Dec 2016 21:42:30 +0530 Subject: [PATCH 05/15] test: [wip] check for self-updates automatically --- src/program.js | 13 ++++++++----- src/util/updates.js | 8 +++++--- tests/unit/test-util/test.updates.js | 26 ++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 tests/unit/test-util/test.updates.js diff --git a/src/program.js b/src/program.js index 6a3a15eb05..a55fb75904 100644 --- a/src/program.js +++ b/src/program.js @@ -9,7 +9,7 @@ import defaultCommands from './cmd'; import {UsageError} from './errors'; import {createLogger, consoleStream as defaultLogStream} from './util/logger'; import {coerceCLICustomPreference} from './firefox/preferences'; -import {checkForAutomaticUpdates} from './util/updates'; +import {checkForAutomaticUpdates as defaultUpdateChecker} from './util/updates'; const log = createLogger(__filename); const envPrefix = 'WEB_EXT'; @@ -22,14 +22,16 @@ export class Program { yargs: any; commands: { [key: string]: Function }; shouldExitProgram: boolean; - checkForUpdates: typeof checkForAutomaticUpdates; + checkForUpdates: typeof defaultUpdateChecker; constructor( argv: ?Array, { absolutePackageDir = process.cwd(), + checkForAutomaticUpdates = defaultUpdateChecker, }: { absolutePackageDir?: string, + checkForAutomaticUpdates: typeof defaultUpdateChecker, } = {} ) { // This allows us to override the process argv which is useful for @@ -119,13 +121,13 @@ export class Program { if (!runCommand) { throw new UsageError(`Unknown command: ${cmd}`); } - + await runCommand(argv); this.checkForUpdates ({ name: 'web-ext', - version: defaultVersionGetter(absolutePackageDir), + version: getVersion(absolutePackageDir), updateCheckInterval: 1000 * 60 * 60 * 24 * 7, + updateNotifier: defaultUpdateChecker, }); - await runCommand(argv); } catch (error) { const prefix = cmd ? `${cmd}: ` : ''; @@ -180,6 +182,7 @@ export function main( ): Promise { const program = new Program(argv, {absolutePackageDir}); + // yargs uses magic camel case expansion to expose options on the // final argv object. For example, the 'artifacts-dir' option is alternatively // available as argv.artifactsDir. diff --git a/src/util/updates.js b/src/util/updates.js index 48cd0e0352..6f525d7124 100644 --- a/src/util/updates.js +++ b/src/util/updates.js @@ -1,19 +1,21 @@ /* @flow */ -import updateNotifier from 'update-notifier'; +import defaultUpdateNotifier from 'update-notifier'; type checkForAutomaticUpdatesParams = { name: string, version: string, - updateCheckInterval: number, + updateCheckInterval?: number, + updateNotifier: typeof defaultUpdateNotifier, }; export function checkForAutomaticUpdates({ name, version, updateCheckInterval, + updateNotifier = defaultUpdateNotifier, }: checkForAutomaticUpdatesParams ) { - let pkg = { + const pkg = { name: name, version: version, }; diff --git a/tests/unit/test-util/test.updates.js b/tests/unit/test-util/test.updates.js new file mode 100644 index 0000000000..80ff1fc43c --- /dev/null +++ b/tests/unit/test-util/test.updates.js @@ -0,0 +1,26 @@ +/* @flow */ +import {it, describe} from 'mocha'; +import {assert} from 'chai'; +import sinon from 'sinon'; + +import {checkForAutomaticUpdates} from '../../../src/util/updates'; + +describe('util/automatic self-updates', () => { + it('calls the notifier with the correct parameters', () => { + let updateNotifierStub = sinon.spy(() => { + return { + notify: sinon.spy(), + }; + }); + + checkForAutomaticUpdates({ + name: 'web-ext', + version: '1.0.0', + updateCheckInterval: 0, + updateNotifier: updateNotifierStub, + }); + assert.equal(updateNotifierStub.firstCall.args[0].pkg.name, 'web-ext'); + assert.equal(updateNotifierStub.firstCall.args[0].pkg.version, '1.0.0'); + assert.equal(updateNotifierStub.firstCall.args[0].updateCheckInterval, 0); + }); +}); \ No newline at end of file From 9c903f1fbabf7cad2484cd7d5c09b45a33678d87 Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Tue, 20 Dec 2016 00:50:12 +0530 Subject: [PATCH 06/15] test: all tests existing pass after adding the notifier for self updates --- src/program.js | 11 +++++++---- tests/unit/test.program.js | 29 ++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/program.js b/src/program.js index a55fb75904..3e5a132776 100644 --- a/src/program.js +++ b/src/program.js @@ -31,7 +31,7 @@ export class Program { checkForAutomaticUpdates = defaultUpdateChecker, }: { absolutePackageDir?: string, - checkForAutomaticUpdates: typeof defaultUpdateChecker, + checkForAutomaticUpdates?: typeof defaultUpdateChecker, } = {} ) { // This allows us to override the process argv which is useful for @@ -93,13 +93,15 @@ export class Program { async execute( absolutePackageDir: string, { - systemProcess = process, logStream = defaultLogStream, - getVersion = defaultVersionGetter, shouldExitProgram = true, + checkForUpdates = defaultUpdateChecker, systemProcess = process, + logStream = defaultLogStream, getVersion = defaultVersionGetter, + shouldExitProgram = true, }: Object = {} ): Promise { this.shouldExitProgram = shouldExitProgram; this.yargs.exitProcess(this.shouldExitProgram); + this.checkForUpdates = checkForUpdates; const argv = this.yargs.argv; const cmd = argv._[0]; @@ -122,10 +124,11 @@ export class Program { throw new UsageError(`Unknown command: ${cmd}`); } await runCommand(argv); + this.checkForUpdates ({ name: 'web-ext', version: getVersion(absolutePackageDir), - updateCheckInterval: 1000 * 60 * 60 * 24 * 7, + updateCheckInterval: 1000 * 60 * 60 * 24 * 7, //1 week updateNotifier: defaultUpdateChecker, }); diff --git a/tests/unit/test.program.js b/tests/unit/test.program.js index 1a27a27350..5a2c8c2e9c 100644 --- a/tests/unit/test.program.js +++ b/tests/unit/test.program.js @@ -26,6 +26,7 @@ describe('program.Program', () => { return program.execute( absolutePackageDir, { systemProcess: fakeProcess, + checkForUpdates: fakeProcess, shouldExitProgram: false, ...options, }); @@ -35,7 +36,9 @@ describe('program.Program', () => { const thing = spy(() => Promise.resolve()); const program = new Program(['thing']) .command('thing', 'does a thing', thing); - return execProgram(program) + return execProgram(program, { + checkForUpdates: spy(), + }) .then(() => { assert.equal(thing.called, true); }); @@ -117,7 +120,9 @@ describe('program.Program', () => { default: 'default value', }, }); - return execProgram(program) + return execProgram(program, { + checkForUpdates: spy(), + }) .then(() => { assert.equal(handler.called, true); // This ensures that the default configuration for the option has @@ -140,7 +145,9 @@ describe('program.Program', () => { default: 'default value', }, }); - return execProgram(program) + return execProgram(program, { + checkForUpdates: spy(), + }) .then(() => { assert.equal(handler.called, true); // By checking the global default, it ensures that default configuration @@ -180,7 +187,11 @@ describe('program.Program', () => { }); program.command('thing', 'does a thing', () => {}); - return execProgram(program, {getVersion: spy(), logStream}) + return execProgram(program, { + getVersion: spy(), + logStream, + checkForUpdates: spy(), + }) .then(() => { assert.equal(logStream.makeVerbose.called, true); }); @@ -195,7 +206,7 @@ describe('program.Program', () => { }, }); program.command('thing', 'does a thing', () => {}); - return execProgram(program, {getVersion: version}) + return execProgram(program, {getVersion: version, checkForUpdates: spy()}) .then(() => { assert.equal(version.firstCall.args[0], path.join(__dirname, '..', '..')); @@ -210,7 +221,7 @@ describe('program.Program', () => { type: 'boolean', }, }); - return execProgram(program, {logStream}) + return execProgram(program, {logStream, checkForUpdates: spy()}) .then(() => { assert.equal(logStream.makeVerbose.called, false); }); @@ -250,7 +261,11 @@ describe('program.Program', () => { describe('program.main', () => { function execProgram(argv, {projectRoot = '', ...mainOptions}: Object = {}) { - const runOptions = {shouldExitProgram: false, systemProcess: fake(process)}; + const runOptions = { + checkForUpdates: spy(), + shouldExitProgram: false, + systemProcess: fake(process), + }; return main(projectRoot, {argv, runOptions, ...mainOptions}); } From 1316d7d806d9873928ccaa455e3d581ab6f2b35c Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Tue, 20 Dec 2016 02:01:08 +0530 Subject: [PATCH 07/15] test: the program object correctly calls the notifier function for checking for self-updates --- src/program.js | 3 --- tests/unit/test.program.js | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/program.js b/src/program.js index 3e5a132776..c25c413a1d 100644 --- a/src/program.js +++ b/src/program.js @@ -28,10 +28,8 @@ export class Program { argv: ?Array, { absolutePackageDir = process.cwd(), - checkForAutomaticUpdates = defaultUpdateChecker, }: { absolutePackageDir?: string, - checkForAutomaticUpdates?: typeof defaultUpdateChecker, } = {} ) { // This allows us to override the process argv which is useful for @@ -45,7 +43,6 @@ export class Program { // config (See web-ext#469 for rationale). const yargsInstance = yargs(argv, absolutePackageDir); - this.checkForUpdates = checkForAutomaticUpdates; this.shouldExitProgram = true; this.yargs = yargsInstance; this.yargs.strict(); diff --git a/tests/unit/test.program.js b/tests/unit/test.program.js index 5a2c8c2e9c..d7e1b4dfda 100644 --- a/tests/unit/test.program.js +++ b/tests/unit/test.program.js @@ -26,7 +26,6 @@ describe('program.Program', () => { return program.execute( absolutePackageDir, { systemProcess: fakeProcess, - checkForUpdates: fakeProcess, shouldExitProgram: false, ...options, }); @@ -255,6 +254,27 @@ describe('program.Program', () => { assert.match(error.message, /Unknown argument: nope/); }); }); + + it('checks for updates automatically', () => { + const root = path.join(__dirname, '..', '..'); + const handler = spy(); + const checkForAutomaticUpdates = sinon.stub(); + const program = new Program(['run']) + .command('run', 'some command', handler); + return execProgram(program, { + checkForUpdates: checkForAutomaticUpdates, + }) + .then(() => { + assert.equal(checkForAutomaticUpdates.firstCall.args[0].name, + 'web-ext'); + let pkgFile = path.join(root, 'package.json'); + return fs.readFile(pkgFile) + .then((pkgData) => { + assert.equal(checkForAutomaticUpdates.firstCall.args[0].version, + JSON.parse(pkgData).version); + }); + }); + }); }); From 0ba8c149b9572c79a631397c7ed32fe6378e6a58 Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Tue, 20 Dec 2016 22:33:03 +0530 Subject: [PATCH 08/15] test: refactored tests, cleaned up program.js and updates.js --- src/program.js | 8 +++---- src/util/updates.js | 15 +++++------- tests/unit/test-util/test.updates.js | 35 ++++++++++++++------------- tests/unit/test.program.js | 36 ++++++++++------------------ 4 files changed, 41 insertions(+), 53 deletions(-) diff --git a/src/program.js b/src/program.js index c25c413a1d..8ad27d339d 100644 --- a/src/program.js +++ b/src/program.js @@ -9,7 +9,7 @@ import defaultCommands from './cmd'; import {UsageError} from './errors'; import {createLogger, consoleStream as defaultLogStream} from './util/logger'; import {coerceCLICustomPreference} from './firefox/preferences'; -import {checkForAutomaticUpdates as defaultUpdateChecker} from './util/updates'; +import {checkForUpdates as defaultUpdateChecker} from './util/updates'; const log = createLogger(__filename); const envPrefix = 'WEB_EXT'; @@ -22,7 +22,6 @@ export class Program { yargs: any; commands: { [key: string]: Function }; shouldExitProgram: boolean; - checkForUpdates: typeof defaultUpdateChecker; constructor( argv: ?Array, @@ -98,7 +97,6 @@ export class Program { this.shouldExitProgram = shouldExitProgram; this.yargs.exitProcess(this.shouldExitProgram); - this.checkForUpdates = checkForUpdates; const argv = this.yargs.argv; const cmd = argv._[0]; @@ -122,10 +120,10 @@ export class Program { } await runCommand(argv); - this.checkForUpdates ({ + checkForUpdates ({ name: 'web-ext', version: getVersion(absolutePackageDir), - updateCheckInterval: 1000 * 60 * 60 * 24 * 7, //1 week + updateCheckInterval: 1000 * 60 * 60 * 24 * 7, // 1 week updateNotifier: defaultUpdateChecker, }); diff --git a/src/util/updates.js b/src/util/updates.js index 6f525d7124..adba75372d 100644 --- a/src/util/updates.js +++ b/src/util/updates.js @@ -1,27 +1,24 @@ /* @flow */ import defaultUpdateNotifier from 'update-notifier'; -type checkForAutomaticUpdatesParams = { +type checkForUpdatesParams = { name: string, version: string, updateCheckInterval?: number, - updateNotifier: typeof defaultUpdateNotifier, + updateNotifier?: typeof defaultUpdateNotifier, }; -export function checkForAutomaticUpdates({ +export function checkForUpdates({ name, version, updateCheckInterval, updateNotifier = defaultUpdateNotifier, -}: checkForAutomaticUpdatesParams +}: checkForUpdatesParams ) { - const pkg = { - name: name, - version: version, - }; + const pkg = {name: 'web-ext', version}; updateNotifier({ pkg, - updateCheckInterval: updateCheckInterval, + updateCheckInterval: 1000 * 60 * 60 * 24 * 7, // 1 week, }).notify(); } \ No newline at end of file diff --git a/tests/unit/test-util/test.updates.js b/tests/unit/test-util/test.updates.js index 80ff1fc43c..20344d4050 100644 --- a/tests/unit/test-util/test.updates.js +++ b/tests/unit/test-util/test.updates.js @@ -3,24 +3,27 @@ import {it, describe} from 'mocha'; import {assert} from 'chai'; import sinon from 'sinon'; -import {checkForAutomaticUpdates} from '../../../src/util/updates'; +import {checkForUpdates} from '../../../src/util/updates'; -describe('util/automatic self-updates', () => { - it('calls the notifier with the correct parameters', () => { - let updateNotifierStub = sinon.spy(() => { - return { - notify: sinon.spy(), - }; - }); +describe('util/updates', () => { + describe('checkForUpdates()', () => { + it('calls the notifier with the correct parameters', () => { + let updateNotifierStub = sinon.spy(() => { + return { + notify: sinon.spy(), + }; + }); - checkForAutomaticUpdates({ - name: 'web-ext', - version: '1.0.0', - updateCheckInterval: 0, - updateNotifier: updateNotifierStub, + checkForUpdates({ + name: 'web-ext', + version: '1.0.0', + updateCheckInterval: 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.equal(updateNotifierStub.firstCall.args[0].updateCheckInterval, 1000 * 60 * 60 * 24 * 7); }); - assert.equal(updateNotifierStub.firstCall.args[0].pkg.name, 'web-ext'); - assert.equal(updateNotifierStub.firstCall.args[0].pkg.version, '1.0.0'); - assert.equal(updateNotifierStub.firstCall.args[0].updateCheckInterval, 0); }); }); \ No newline at end of file diff --git a/tests/unit/test.program.js b/tests/unit/test.program.js index d7e1b4dfda..9eb90990d2 100644 --- a/tests/unit/test.program.js +++ b/tests/unit/test.program.js @@ -7,11 +7,7 @@ import {fs} from 'mz'; import sinon, {spy} from 'sinon'; import {assert} from 'chai'; -import { - defaultVersionGetter, - main, - Program, -} from '../../src/program'; +import {defaultVersionGetter, main, Program} from '../../src/program'; import commands from '../../src/cmd'; import {onlyInstancesOf, UsageError} from '../../src/errors'; import {fake, makeSureItFails} from './helpers'; @@ -25,6 +21,7 @@ describe('program.Program', () => { const absolutePackageDir = path.join(__dirname, '..', '..'); return program.execute( absolutePackageDir, { + checkForUpdates: spy(), systemProcess: fakeProcess, shouldExitProgram: false, ...options, @@ -35,9 +32,7 @@ describe('program.Program', () => { const thing = spy(() => Promise.resolve()); const program = new Program(['thing']) .command('thing', 'does a thing', thing); - return execProgram(program, { - checkForUpdates: spy(), - }) + return execProgram(program) .then(() => { assert.equal(thing.called, true); }); @@ -119,9 +114,7 @@ describe('program.Program', () => { default: 'default value', }, }); - return execProgram(program, { - checkForUpdates: spy(), - }) + return execProgram(program) .then(() => { assert.equal(handler.called, true); // This ensures that the default configuration for the option has @@ -144,9 +137,7 @@ describe('program.Program', () => { default: 'default value', }, }); - return execProgram(program, { - checkForUpdates: spy(), - }) + return execProgram(program) .then(() => { assert.equal(handler.called, true); // By checking the global default, it ensures that default configuration @@ -189,7 +180,6 @@ describe('program.Program', () => { return execProgram(program, { getVersion: spy(), logStream, - checkForUpdates: spy(), }) .then(() => { assert.equal(logStream.makeVerbose.called, true); @@ -205,7 +195,7 @@ describe('program.Program', () => { }, }); program.command('thing', 'does a thing', () => {}); - return execProgram(program, {getVersion: version, checkForUpdates: spy()}) + return execProgram(program, {getVersion: version}) .then(() => { assert.equal(version.firstCall.args[0], path.join(__dirname, '..', '..')); @@ -220,7 +210,7 @@ describe('program.Program', () => { type: 'boolean', }, }); - return execProgram(program, {logStream, checkForUpdates: spy()}) + return execProgram(program, {logStream}) .then(() => { assert.equal(logStream.makeVerbose.called, false); }); @@ -257,24 +247,24 @@ describe('program.Program', () => { it('checks for updates automatically', () => { const root = path.join(__dirname, '..', '..'); + const pkgFile = path.join(root, 'package.json'); const handler = spy(); const checkForAutomaticUpdates = sinon.stub(); const program = new Program(['run']) - .command('run', 'some command', handler); + .command('run', 'some command', handler); return execProgram(program, { checkForUpdates: checkForAutomaticUpdates, }) .then(() => { assert.equal(checkForAutomaticUpdates.firstCall.args[0].name, 'web-ext'); - let pkgFile = path.join(root, 'package.json'); return fs.readFile(pkgFile) - .then((pkgData) => { - assert.equal(checkForAutomaticUpdates.firstCall.args[0].version, + }) + .then((pkgData) => { + assert.equal(checkForAutomaticUpdates.firstCall.args[0].version, JSON.parse(pkgData).version); - }); }); - }); + }); }); From 5973f2809bbff3f370ce0686916caccbcc90f025 Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Tue, 20 Dec 2016 22:39:59 +0530 Subject: [PATCH 09/15] fix: fixed eslint errors --- src/program.js | 2 -- src/util/updates.js | 4 ---- tests/unit/test-util/test.updates.js | 3 ++- tests/unit/test.program.js | 6 +++--- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/program.js b/src/program.js index 8ad27d339d..92fb8a4268 100644 --- a/src/program.js +++ b/src/program.js @@ -121,9 +121,7 @@ export class Program { await runCommand(argv); checkForUpdates ({ - name: 'web-ext', version: getVersion(absolutePackageDir), - updateCheckInterval: 1000 * 60 * 60 * 24 * 7, // 1 week updateNotifier: defaultUpdateChecker, }); diff --git a/src/util/updates.js b/src/util/updates.js index adba75372d..ec4eb8a8dd 100644 --- a/src/util/updates.js +++ b/src/util/updates.js @@ -2,16 +2,12 @@ import defaultUpdateNotifier from 'update-notifier'; type checkForUpdatesParams = { - name: string, version: string, - updateCheckInterval?: number, updateNotifier?: typeof defaultUpdateNotifier, }; export function checkForUpdates({ - name, version, - updateCheckInterval, updateNotifier = defaultUpdateNotifier, }: checkForUpdatesParams ) { diff --git a/tests/unit/test-util/test.updates.js b/tests/unit/test-util/test.updates.js index 20344d4050..9564294526 100644 --- a/tests/unit/test-util/test.updates.js +++ b/tests/unit/test-util/test.updates.js @@ -23,7 +23,8 @@ describe('util/updates', () => { 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.equal(updateNotifierStub.firstCall.args[0].updateCheckInterval, 1000 * 60 * 60 * 24 * 7); + assert.equal(updateNotifierStub.firstCall.args[0].updateCheckInterval, + 1000 * 60 * 60 * 24 * 7); }); }); }); \ No newline at end of file diff --git a/tests/unit/test.program.js b/tests/unit/test.program.js index 9eb90990d2..ccf104ecc5 100644 --- a/tests/unit/test.program.js +++ b/tests/unit/test.program.js @@ -258,13 +258,13 @@ describe('program.Program', () => { .then(() => { assert.equal(checkForAutomaticUpdates.firstCall.args[0].name, 'web-ext'); - return fs.readFile(pkgFile) + return fs.readFile(pkgFile); }) .then((pkgData) => { - assert.equal(checkForAutomaticUpdates.firstCall.args[0].version, + assert.equal(checkForAutomaticUpdates.firstCall.args[0].version, JSON.parse(pkgData).version); }); - }); + }); }); From 760213171ed743461d437d0957b93c27d4df62c0 Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Tue, 20 Dec 2016 23:53:01 +0530 Subject: [PATCH 10/15] fix: style nits --- src/program.js | 1 - src/util/updates.js | 13 +++++++------ tests/unit/test-util/test.updates.js | 4 +--- tests/unit/test.program.js | 12 ++++-------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/program.js b/src/program.js index 92fb8a4268..3071b4805e 100644 --- a/src/program.js +++ b/src/program.js @@ -122,7 +122,6 @@ export class Program { checkForUpdates ({ version: getVersion(absolutePackageDir), - updateNotifier: defaultUpdateChecker, }); } catch (error) { diff --git a/src/util/updates.js b/src/util/updates.js index ec4eb8a8dd..92edeecf8b 100644 --- a/src/util/updates.js +++ b/src/util/updates.js @@ -1,15 +1,16 @@ /* @flow */ import defaultUpdateNotifier from 'update-notifier'; -type checkForUpdatesParams = { +type checkForUpdatesParams = {| version: string, updateNotifier?: typeof defaultUpdateNotifier, -}; +|}; -export function checkForUpdates({ - version, - updateNotifier = defaultUpdateNotifier, -}: checkForUpdatesParams +export function checkForUpdates( + { + version, + updateNotifier = defaultUpdateNotifier, + }: checkForUpdatesParams ) { const pkg = {name: 'web-ext', version}; diff --git a/tests/unit/test-util/test.updates.js b/tests/unit/test-util/test.updates.js index 9564294526..622ee6a91c 100644 --- a/tests/unit/test-util/test.updates.js +++ b/tests/unit/test-util/test.updates.js @@ -8,16 +8,14 @@ import {checkForUpdates} from '../../../src/util/updates'; describe('util/updates', () => { describe('checkForUpdates()', () => { it('calls the notifier with the correct parameters', () => { - let updateNotifierStub = sinon.spy(() => { + const updateNotifierStub = sinon.spy(() => { return { notify: sinon.spy(), }; }); checkForUpdates({ - name: 'web-ext', version: '1.0.0', - updateCheckInterval: 0, updateNotifier: updateNotifierStub, }); assert.equal(updateNotifierStub.called, true); diff --git a/tests/unit/test.program.js b/tests/unit/test.program.js index ccf104ecc5..146002155d 100644 --- a/tests/unit/test.program.js +++ b/tests/unit/test.program.js @@ -252,17 +252,13 @@ describe('program.Program', () => { const checkForAutomaticUpdates = sinon.stub(); const program = new Program(['run']) .command('run', 'some command', handler); - return execProgram(program, { + execProgram(program, { checkForUpdates: checkForAutomaticUpdates, - }) - .then(() => { - assert.equal(checkForAutomaticUpdates.firstCall.args[0].name, - 'web-ext'); - return fs.readFile(pkgFile); - }) + }); + return fs.readFile(pkgFile) .then((pkgData) => { assert.equal(checkForAutomaticUpdates.firstCall.args[0].version, - JSON.parse(pkgData).version); + JSON.parse(pkgData).version); }); }); }); From 4088d494db896b10f2baa4b2c4f403fcc21de06d Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Wed, 21 Dec 2016 23:06:16 +0530 Subject: [PATCH 11/15] test: fixed test to work in both development and production environment --- src/program.js | 7 ++++--- tests/unit/test.program.js | 10 ++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/program.js b/src/program.js index 3071b4805e..359ea737e7 100644 --- a/src/program.js +++ b/src/program.js @@ -14,6 +14,9 @@ import {checkForUpdates as defaultUpdateChecker} from './util/updates'; const log = createLogger(__filename); const envPrefix = 'WEB_EXT'; +type ProgramOptions = { + absolutePackageDir?: string, +} /* * The command line program. @@ -27,9 +30,7 @@ export class Program { argv: ?Array, { absolutePackageDir = process.cwd(), - }: { - absolutePackageDir?: string, - } = {} + }: ProgramOptions = {} ) { // This allows us to override the process argv which is useful for // testing. diff --git a/tests/unit/test.program.js b/tests/unit/test.program.js index 146002155d..8d09dcd39c 100644 --- a/tests/unit/test.program.js +++ b/tests/unit/test.program.js @@ -247,18 +247,16 @@ describe('program.Program', () => { it('checks for updates automatically', () => { const root = path.join(__dirname, '..', '..'); - const pkgFile = path.join(root, 'package.json'); const handler = spy(); const checkForAutomaticUpdates = sinon.stub(); const program = new Program(['run']) .command('run', 'some command', handler); - execProgram(program, { + return execProgram(program, { checkForUpdates: checkForAutomaticUpdates, - }); - return fs.readFile(pkgFile) - .then((pkgData) => { + }) + .then(() => { assert.equal(checkForAutomaticUpdates.firstCall.args[0].version, - JSON.parse(pkgData).version); + defaultVersionGetter(root)); }); }); }); From 79cf3be99f6b6cb388b05eb299c5df79ec76bb2f Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Thu, 22 Dec 2016 00:17:04 +0530 Subject: [PATCH 12/15] fix: style nits and stubbed getVersion() for tests not related to versions --- src/program.js | 7 ++++--- src/util/updates.js | 2 +- tests/unit/test-util/test.updates.js | 2 +- tests/unit/test.program.js | 13 ++++++++----- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/program.js b/src/program.js index 359ea737e7..468f40d6ad 100644 --- a/src/program.js +++ b/src/program.js @@ -14,9 +14,9 @@ import {checkForUpdates as defaultUpdateChecker} from './util/updates'; const log = createLogger(__filename); const envPrefix = 'WEB_EXT'; -type ProgramOptions = { +type ProgramOptions = {| absolutePackageDir?: string, -} +|} /* * The command line program. @@ -119,12 +119,13 @@ export class Program { if (!runCommand) { throw new UsageError(`Unknown command: ${cmd}`); } - await runCommand(argv); checkForUpdates ({ version: getVersion(absolutePackageDir), }); + await runCommand(argv); + } catch (error) { const prefix = cmd ? `${cmd}: ` : ''; if (!(error instanceof UsageError) || argv.verbose) { diff --git a/src/util/updates.js b/src/util/updates.js index 92edeecf8b..12194103de 100644 --- a/src/util/updates.js +++ b/src/util/updates.js @@ -10,7 +10,7 @@ export function checkForUpdates( { version, updateNotifier = defaultUpdateNotifier, - }: checkForUpdatesParams + }: checkForUpdatesParams ) { const pkg = {name: 'web-ext', version}; diff --git a/tests/unit/test-util/test.updates.js b/tests/unit/test-util/test.updates.js index 622ee6a91c..1e6bb26214 100644 --- a/tests/unit/test-util/test.updates.js +++ b/tests/unit/test-util/test.updates.js @@ -22,7 +22,7 @@ describe('util/updates', () => { assert.equal(updateNotifierStub.firstCall.args[0].pkg.name, 'web-ext'); assert.equal(updateNotifierStub.firstCall.args[0].pkg.version, '1.0.0'); assert.equal(updateNotifierStub.firstCall.args[0].updateCheckInterval, - 1000 * 60 * 60 * 24 * 7); + 1000 * 60 * 60 * 24 * 7); }); }); }); \ No newline at end of file diff --git a/tests/unit/test.program.js b/tests/unit/test.program.js index 8d09dcd39c..cbcad95d31 100644 --- a/tests/unit/test.program.js +++ b/tests/unit/test.program.js @@ -21,6 +21,7 @@ describe('program.Program', () => { const absolutePackageDir = path.join(__dirname, '..', '..'); return program.execute( absolutePackageDir, { + getVersion: () => 'not-a-real-version', checkForUpdates: spy(), systemProcess: fakeProcess, shouldExitProgram: false, @@ -246,17 +247,18 @@ describe('program.Program', () => { }); it('checks for updates automatically', () => { - const root = path.join(__dirname, '..', '..'); const handler = spy(); - const checkForAutomaticUpdates = sinon.stub(); + const getVersion = () => 'some-package-version'; + const checkForUpdates = sinon.stub(); const program = new Program(['run']) .command('run', 'some command', handler); return execProgram(program, { - checkForUpdates: checkForAutomaticUpdates, + checkForUpdates, + getVersion, }) .then(() => { - assert.equal(checkForAutomaticUpdates.firstCall.args[0].version, - defaultVersionGetter(root)); + assert.equal(checkForUpdates.firstCall.args[0].version, + 'some-package-version'); }); }); }); @@ -266,6 +268,7 @@ describe('program.main', () => { function execProgram(argv, {projectRoot = '', ...mainOptions}: Object = {}) { const runOptions = { + getVersion: () => 'not-a-real-version', checkForUpdates: spy(), shouldExitProgram: false, systemProcess: fake(process), From 09da85ae46bb0ca42bad92c42e8ff82cc71d9717 Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Thu, 22 Dec 2016 00:30:16 +0530 Subject: [PATCH 13/15] fix: checking for updates is disable during development --- package.json | 2 +- src/program.js | 11 ++++++----- tests/unit/test.program.js | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index c1103175b7..5993290e81 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "mz": "2.6.0", "node-firefox-connect": "1.2.0", "parse-json": "2.2.0", - "regenerator-runtime": "0.10.0", + "regenerator-runtime": "0.10.1", "sign-addon": "0.2.0", "source-map-support": "0.4.7", "stream-to-promise": "2.2.0", diff --git a/src/program.js b/src/program.js index 468f40d6ad..9cf2c134e5 100644 --- a/src/program.js +++ b/src/program.js @@ -92,7 +92,7 @@ export class Program { { checkForUpdates = defaultUpdateChecker, systemProcess = process, logStream = defaultLogStream, getVersion = defaultVersionGetter, - shouldExitProgram = true, + shouldExitProgram = true, localEnv = 'development', }: Object = {} ): Promise { @@ -119,10 +119,11 @@ export class Program { if (!runCommand) { throw new UsageError(`Unknown command: ${cmd}`); } - - checkForUpdates ({ - version: getVersion(absolutePackageDir), - }); + if (localEnv === 'production') { + checkForUpdates ({ + version: getVersion(absolutePackageDir), + }); + } await runCommand(argv); diff --git a/tests/unit/test.program.js b/tests/unit/test.program.js index cbcad95d31..f2b194e154 100644 --- a/tests/unit/test.program.js +++ b/tests/unit/test.program.js @@ -255,6 +255,7 @@ describe('program.Program', () => { return execProgram(program, { checkForUpdates, getVersion, + localEnv: 'production', }) .then(() => { assert.equal(checkForUpdates.firstCall.args[0].version, From 336d0b655d6f629a1bb90802a5e4d008551d96b5 Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Thu, 22 Dec 2016 21:25:23 +0530 Subject: [PATCH 14/15] test: added test for disabling checking of updates during development --- src/program.js | 2 +- tests/unit/test-util/test.updates.js | 2 +- tests/unit/test.program.js | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/program.js b/src/program.js index 9cf2c134e5..0e47dec696 100644 --- a/src/program.js +++ b/src/program.js @@ -92,7 +92,7 @@ export class Program { { checkForUpdates = defaultUpdateChecker, systemProcess = process, logStream = defaultLogStream, getVersion = defaultVersionGetter, - shouldExitProgram = true, localEnv = 'development', + shouldExitProgram = true, localEnv = WEBEXT_BUILD_ENV, }: Object = {} ): Promise { diff --git a/tests/unit/test-util/test.updates.js b/tests/unit/test-util/test.updates.js index 1e6bb26214..024b135c86 100644 --- a/tests/unit/test-util/test.updates.js +++ b/tests/unit/test-util/test.updates.js @@ -22,7 +22,7 @@ describe('util/updates', () => { assert.equal(updateNotifierStub.firstCall.args[0].pkg.name, 'web-ext'); assert.equal(updateNotifierStub.firstCall.args[0].pkg.version, '1.0.0'); assert.equal(updateNotifierStub.firstCall.args[0].updateCheckInterval, - 1000 * 60 * 60 * 24 * 7); + 1000 * 60 * 60 * 24 * 7); }); }); }); \ No newline at end of file diff --git a/tests/unit/test.program.js b/tests/unit/test.program.js index f2b194e154..adaf0db634 100644 --- a/tests/unit/test.program.js +++ b/tests/unit/test.program.js @@ -262,6 +262,22 @@ describe('program.Program', () => { 'some-package-version'); }); }); + + it('does not check for updates during development', () => { + const handler = spy(); + const getVersion = () => 'some-package-version'; + const checkForUpdates = sinon.stub(); + const program = new Program(['run']) + .command('run', 'some command', handler); + return execProgram(program, { + checkForUpdates, + getVersion, + localEnv: 'development', + }) + .then(() => { + assert.equal(checkForUpdates.called, false); + }); + }); }); From fe962f6329a1d5fdf6ab56dbc1865a3850214460 Mon Sep 17 00:00:00 2001 From: Shubheksha Jalan Date: Fri, 23 Dec 2016 23:39:27 +0530 Subject: [PATCH 15/15] refactor: changed localEnv to globalEnv, reduced update interval to 3 days --- src/program.js | 10 +++++----- src/util/updates.js | 2 +- tests/unit/test-util/test.updates.js | 3 ++- tests/unit/test.program.js | 10 +++++----- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/program.js b/src/program.js index 0e47dec696..f816b20436 100644 --- a/src/program.js +++ b/src/program.js @@ -92,7 +92,7 @@ export class Program { { checkForUpdates = defaultUpdateChecker, systemProcess = process, logStream = defaultLogStream, getVersion = defaultVersionGetter, - shouldExitProgram = true, localEnv = WEBEXT_BUILD_ENV, + shouldExitProgram = true, globalEnv = WEBEXT_BUILD_ENV, }: Object = {} ): Promise { @@ -119,7 +119,7 @@ export class Program { if (!runCommand) { throw new UsageError(`Unknown command: ${cmd}`); } - if (localEnv === 'production') { + if (globalEnv === 'production') { checkForUpdates ({ version: getVersion(absolutePackageDir), }); @@ -152,14 +152,14 @@ declare var WEBEXT_BUILD_ENV: string; //A defintion of type of argument for defaultVersionGetter type versionGetterOptions = { - localEnv?: string, + globalEnv?: string, }; export function defaultVersionGetter( absolutePackageDir: string, - {localEnv = WEBEXT_BUILD_ENV}: versionGetterOptions = {} + {globalEnv = WEBEXT_BUILD_ENV}: versionGetterOptions = {} ): string { - if (localEnv === 'production') { + if (globalEnv === 'production') { log.debug('Getting the version from package.json'); const packageData: any = readFileSync( path.join(absolutePackageDir, 'package.json')); diff --git a/src/util/updates.js b/src/util/updates.js index 12194103de..0f61f12d00 100644 --- a/src/util/updates.js +++ b/src/util/updates.js @@ -16,6 +16,6 @@ export function checkForUpdates( updateNotifier({ pkg, - updateCheckInterval: 1000 * 60 * 60 * 24 * 7, // 1 week, + updateCheckInterval: 1000 * 60 * 60 * 24 * 3, // 3 days, }).notify(); } \ No newline at end of file diff --git a/tests/unit/test-util/test.updates.js b/tests/unit/test-util/test.updates.js index 024b135c86..ad7ba28e25 100644 --- a/tests/unit/test-util/test.updates.js +++ b/tests/unit/test-util/test.updates.js @@ -21,8 +21,9 @@ describe('util/updates', () => { 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 * 7); + 1000 * 60 * 60 * 24 * 3); }); }); }); \ No newline at end of file diff --git a/tests/unit/test.program.js b/tests/unit/test.program.js index adaf0db634..5869f55070 100644 --- a/tests/unit/test.program.js +++ b/tests/unit/test.program.js @@ -21,7 +21,7 @@ describe('program.Program', () => { const absolutePackageDir = path.join(__dirname, '..', '..'); return program.execute( absolutePackageDir, { - getVersion: () => 'not-a-real-version', + getVersion: () => spy(), checkForUpdates: spy(), systemProcess: fakeProcess, shouldExitProgram: false, @@ -255,7 +255,7 @@ describe('program.Program', () => { return execProgram(program, { checkForUpdates, getVersion, - localEnv: 'production', + globalEnv: 'production', }) .then(() => { assert.equal(checkForUpdates.firstCall.args[0].version, @@ -272,7 +272,7 @@ describe('program.Program', () => { return execProgram(program, { checkForUpdates, getVersion, - localEnv: 'development', + globalEnv: 'development', }) .then(() => { assert.equal(checkForUpdates.called, false); @@ -393,7 +393,7 @@ describe('program.defaultVersionGetter', () => { const pkgFile = path.join(root, 'package.json'); return fs.readFile(pkgFile) .then((pkgData) => { - const testBuildEnv = {localEnv: 'production'}; + const testBuildEnv = {globalEnv: 'production'}; assert.equal(defaultVersionGetter(root, testBuildEnv), JSON.parse(pkgData).version); }); @@ -401,7 +401,7 @@ describe('program.defaultVersionGetter', () => { it('returns git commit information in development', () => { const commit = `${git.branch()}-${git.long()}`; - const testBuildEnv = {localEnv: 'development'}; + const testBuildEnv = {globalEnv: 'development'}; assert.equal(defaultVersionGetter(root, testBuildEnv), commit); });