diff --git a/src/lib/upgradePackageDefinitions.ts b/src/lib/upgradePackageDefinitions.ts index 38632565..4a78583f 100644 --- a/src/lib/upgradePackageDefinitions.ts +++ b/src/lib/upgradePackageDefinitions.ts @@ -46,8 +46,10 @@ export async function upgradePackageDefinitions( return !options.jsonUpgraded || !options.minimal || !satisfies(latestVersions[dep], currentDependencies[dep]) }) + const filteredLatestDependencies = pickBy(latestVersions, (spec, dep) => filteredUpgradedDependencies[dep]) + if (options.peer && !isEmpty(filteredUpgradedDependencies)) { - const upgradedPeerDependencies = await getPeerDependenciesFromRegistry(filteredUpgradedDependencies, options) + const upgradedPeerDependencies = await getPeerDependenciesFromRegistry(filteredLatestDependencies, options) const peerDependencies = { ...options.peerDependencies, ...upgradedPeerDependencies } if (!isEqual(options.peerDependencies, peerDependencies)) { const [newUpgradedDependencies, newLatestVersions, newPeerDependencies] = await upgradePackageDefinitions( diff --git a/src/package-managers/npm.ts b/src/package-managers/npm.ts index 45fe5c24..514afda2 100644 --- a/src/package-managers/npm.ts +++ b/src/package-managers/npm.ts @@ -638,11 +638,7 @@ export const greatest: GetVersion = async ( * @returns Promised {packageName: version} collection */ export const getPeerDependencies = async (packageName: string, version: Version): Promise> => { - // if version number uses >, omit the version and find latest - // otherwise, it will error out in the shell - // https://github.com/raineorshine/npm-check-updates/issues/1181 - const atVersion = !version.startsWith('>') ? `@${version}` : '' - const args = ['view', `${packageName}${atVersion}`, 'peerDependencies'] + const args = ['view', `${packageName}@${version}`, 'peerDependencies'] const result = await spawnNpm(args, {}, { rejectOnError: false }) return result ? parseJson(result, { command: [...args, '--json'].join(' ') }) : {} }