Git Branch Lockfiles
Added in: v7.3.0
Git branch lockfiles 允许您完全避免 lockfile 合并冲突并稍后解决。
使用 git branch lockfiles
您可以通过配置 .npmrc 文件来打开此功能。
git-branch-lockfile=true
通过这样做,lockfile 文件的名称将根据当前 git 分支名称生成。
例如,当前分支名称是 feature-1。 那么,生成的 lockfile 文件名称就会是 pnpm-lock.feature-1.yaml。 您可以将其提交到 Git,并稍后合并所有 git branch lockfiles 文件。
- <项目目录>
|- pnpm-lock.yaml
|- pnpm-lock.feature-1.yaml
|- pnpm-lock.<分支名称>.yaml
NOTE: feature/1 is special in that the / is automatically converted to !, so the corresponding lockfile name would be pnpm-lock.feature!1.yaml.
合并 git branch lockfiles
pnpm install --merge-git-branch-lockfiles
要合并所有 git branch lockfiles,只需要在运行 pnpm install 命令时指定 --merge-git-branch-lockfiles。
运行后,所有 git branch lockfiles 将会合并成一个 pnpm-lock.yaml
分支匹配
Pnpm allows you to specify --merge-git-branch-lockfiles by matching the current branch name.
For instance,
By the following setting in .npmrc file, pnpm install will merge all git branch lockfiles when running in the main branch and the branch name starts with release.
merge-git-branch-lockfiles-branch-pattern[]=main
merge-git-branch-lockfiles-branch-pattern[]=release*