diff --git a/__tests__/commands/upgrade-interactive.js b/__tests__/commands/upgrade-interactive.js index 1738603706..c1525333eb 100644 --- a/__tests__/commands/upgrade-interactive.js +++ b/__tests__/commands/upgrade-interactive.js @@ -10,7 +10,6 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000; const path = require('path'); const fixturesLoc = path.join(__dirname, '..', 'fixtures', 'upgrade-interactive'); -// I would have named it `runUpgradeInteractive`, but that was causing linting to fail. const runUpgrade = buildRun.bind(null, ConsoleReporter, fixturesLoc, (args, flags, config, reporter): Promise => { return upgradeInteractive(config, reporter, flags, args); }); @@ -27,3 +26,10 @@ test.concurrent('throws if lockfile is out of date', (): Promise => { } }); }); + +test.concurrent('exits with success if no upgrades', (): Promise => { + const reporter = new reporters.ConsoleReporter({}); + return runUpgrade([], {}, 'up-to-date', (config, rep, install, output): ?Promise => { + expect(output()).toContain(reporter.lang('allDependenciesUpToDate')); + }); +}); diff --git a/__tests__/fixtures/upgrade-interactive/up-to-date/package.json b/__tests__/fixtures/upgrade-interactive/up-to-date/package.json new file mode 100644 index 0000000000..bdcc099166 --- /dev/null +++ b/__tests__/fixtures/upgrade-interactive/up-to-date/package.json @@ -0,0 +1,9 @@ +{ + "name": "yarn-test", + "version": "1.0.0", + "main": "index.js", + "license": "MIT", + "dependencies": { + "left-pad": "^1.1.3" + } +} diff --git a/__tests__/fixtures/upgrade-interactive/up-to-date/yarn.lock b/__tests__/fixtures/upgrade-interactive/up-to-date/yarn.lock new file mode 100644 index 0000000000..25a2c512a8 --- /dev/null +++ b/__tests__/fixtures/upgrade-interactive/up-to-date/yarn.lock @@ -0,0 +1,7 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +left-pad@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.1.3.tgz#612f61c033f3a9e08e939f1caebeea41b6f3199a" diff --git a/src/cli/commands/upgrade-interactive.js b/src/cli/commands/upgrade-interactive.js index ed3c391f49..771bd1f15e 100644 --- a/src/cli/commands/upgrade-interactive.js +++ b/src/cli/commands/upgrade-interactive.js @@ -44,6 +44,11 @@ export async function run(config: Config, reporter: Reporter, flags: Object, arg [outdatedFieldName]: 'to'.length, }; + if (deps.length === 0) { + reporter.success(reporter.lang('allDependenciesUpToDate')); + return; + } + if (flags.latest) { maxLengthArr.range = 'latest'.length; }