Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(link): change package version when exec link #4375

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/core/src/link/index.ts
Expand Up @@ -17,12 +17,14 @@ import {
getSpecFromPackageManifest,
guessDependencyType,
PackageSpecObject,
PinnedVersion,
updateProjectManifestObject,
} from '@pnpm/manifest-utils'
import { prune } from '@pnpm/modules-cleaner'
import { pruneSharedLockfile } from '@pnpm/prune-lockfile'
import readProjectManifest from '@pnpm/read-project-manifest'
import { symlinkDirectRootDependency } from '@pnpm/symlink-dependency'
import whichVersionIsPinned from '@pnpm/which-version-is-pinned'
import {
DependenciesField,
DEPENDENCIES_FIELDS,
Expand Down Expand Up @@ -78,10 +80,17 @@ export default async function link (
throw new PnpmError('INVALID_PACKAGE_NAME', `Package in ${linkFromPath} must have a name field to be linked`)
}

let pinnedVersion!: PinnedVersion
const existingVersion = opts.manifest?.dependencies?.[manifest.name]
if (existingVersion) {
pinnedVersion = whichVersionIsPinned(existingVersion) ?? opts.pinnedVersion
} else {
pinnedVersion = opts.pinnedVersion
}
specsToUpsert.push({
alias: manifest.name,
pref: getPref(manifest.name, manifest.name, manifest.version, {
pinnedVersion: opts.pinnedVersion,
pinnedVersion,
}),
saveType: (opts.targetDependenciesField ?? (ctx.manifest && guessDependencyType(manifest.name, ctx.manifest))) as DependenciesField,
})
Expand Down