Skip to content

Commit

Permalink
upgrade-interactive exit success when no upgrades (yarnpkg#4261)
Browse files Browse the repository at this point in the history
* [yarnpkg#4259] upgrade-interactive exit success when no upgrades
* added test for upgrade-interactive all up to date
  • Loading branch information
rally25rs authored Aug 25, 2017
1 parent d47a2bf commit f872cc7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
8 changes: 7 additions & 1 deletion __tests__/commands/upgrade-interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> => {
return upgradeInteractive(config, reporter, flags, args);
});
Expand All @@ -27,3 +26,10 @@ test.concurrent('throws if lockfile is out of date', (): Promise<void> => {
}
});
});

test.concurrent('exits with success if no upgrades', (): Promise<void> => {
const reporter = new reporters.ConsoleReporter({});
return runUpgrade([], {}, 'up-to-date', (config, rep, install, output): ?Promise<void> => {
expect(output()).toContain(reporter.lang('allDependenciesUpToDate'));
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "yarn-test",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"left-pad": "^1.1.3"
}
}
7 changes: 7 additions & 0 deletions __tests__/fixtures/upgrade-interactive/up-to-date/yarn.lock
Original file line number Diff line number Diff line change
@@ -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"
5 changes: 5 additions & 0 deletions src/cli/commands/upgrade-interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f872cc7

Please sign in to comment.