Skip to content

Commit

Permalink
Don't use ^ for --pin'd overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jan 21, 2025
1 parent 987bfcf commit ae99d38
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/commands/optimize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ async function addOverrides(
const oldSpec = overrideExists ? overrides[origPkgName] : undefined
const depAlias = depAliasMap.get(origPkgName)
const regSpecStartsLike = `${NPM}:${regPkgName}@`
let newSpec = `${regSpecStartsLike}^${pin ? version : major}`
let newSpec = `${regSpecStartsLike}${pin ? version : `^${major}`}`
let thisVersion = version
if (depAlias && type === NPM) {
// With npm one may not set an override for a package that one directly
Expand All @@ -742,7 +742,7 @@ async function addOverrides(
: ((await fetchPackageManifest(thisSpec))?.version ??
version)
}
newSpec = `${regSpecStartsLike}^${pin ? thisVersion : semver.major(thisVersion)}`
newSpec = `${regSpecStartsLike}${pin ? thisVersion : `^${semver.major(thisVersion)}`}`
} else {
newSpec = oldSpec
}
Expand Down

0 comments on commit ae99d38

Please sign in to comment.