Skip to content

Commit

Permalink
Don't outpudate list if all dependencies are up to date - fixes yarnp…
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian McKenzie authored and bestander committed Nov 15, 2016
1 parent 4b93ea5 commit 567f8af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/cli/commands/upgrade-interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function run(
const install = new Install(flags, config, reporter, lockfile);
const [deps] = await install.fetchRequestFromCwd();

const allDeps = (await Promise.all(deps.map(async ({pattern, hint}): Promise<Dependency> => {
const allDeps = await Promise.all(deps.map(async ({pattern, hint}): Promise<Dependency> => {
const locked = lockfile.getLocked(pattern);
if (!locked) {
throw new MessageError(reporter.lang('lockfileOutdated'));
Expand All @@ -77,14 +77,19 @@ export async function run(
}

return ({name, current, wanted, latest, hint});
})));
}));

const isDepOld = ({latest, current}) => latest !== 'exotic' && semver.lt(current, latest);
const isDepExpected = ({current, wanted}) => current === wanted;
const orderByExpected = (depA, depB) => isDepExpected(depA) && !isDepExpected(depB) ? 1 : -1;

const outdatedDeps = allDeps.filter(isDepOld).sort(orderByExpected);

if (!outdatedDeps.length) {
reporter.success(reporter.lang('allDependenciesUpToDate'));
return;
}

const getNameFromHint = (hint) => hint ? `${hint}Dependencies` : 'dependencies';

const maxLengthArr = {name: 0, current: 0, latest: 0};
Expand Down
1 change: 1 addition & 0 deletions src/reporters/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const messages = {
unexpectedError: 'An unexpected error occurred: $0.',
jsonError: 'Error parsing JSON at $0, $1.',
noFilePermission: "We don't have permissions to touch the file $0.",
allDependenciesUpToDate: 'All of your dependencies are up to date.',

yarnOutdated: "Your current version of Yarn is out of date. The latest version is $0 while you're on $1.",
yarnOutdatedInstaller: 'To upgrade, download the latest installer at $0.',
Expand Down

0 comments on commit 567f8af

Please sign in to comment.