-
-
Notifications
You must be signed in to change notification settings - Fork 973
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: don't write pnpm-lock.yaml
if it has no changes
#6260
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@pnpm/get-context": minor | ||
--- | ||
|
||
Return a copy of the wantedLockfile (wantedLockfileUnmodified) for checking later on if the lockfile was modified. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@pnpm/core": patch | ||
"pnpm": patch | ||
--- | ||
|
||
Don't write the `pnpm-lock.yaml` file if it has no changes and `pnpm install --frozen-lockfile` was executed [#6158](https://github.com/pnpm/pnpm/issues/6158). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@pnpm/headless": minor | ||
--- | ||
|
||
A new option is accepted: wantedLockfileUnmodified. It is used to check if the wanted lockfile was changed and whether it needs to be written. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,6 +146,7 @@ export interface HeadlessOptions { | |
pruneStore: boolean | ||
pruneVirtualStore?: boolean | ||
wantedLockfile?: Lockfile | ||
wantedLockfileUnmodified?: Lockfile | ||
ownLifecycleHooksStdio?: 'inherit' | 'pipe' | ||
pendingBuilds: string[] | ||
resolveSymlinksInInjectedDirs?: boolean | ||
|
@@ -545,7 +546,7 @@ export async function headlessInstall (opts: HeadlessOptions) { | |
storeDir: opts.storeDir, | ||
virtualStoreDir, | ||
}) | ||
if (opts.useLockfile) { | ||
if (opts.useLockfile && JSON.stringify(wantedLockfile) !== JSON.stringify(opts.wantedLockfileUnmodified)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: It might be worth following up with a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have changed it. There was actually no need in the copy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
// We need to write the wanted lockfile as well. | ||
// Even though it will only be changed if the workspace will have new projects with no dependencies. | ||
await writeLockfiles({ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It might be worth a comment that we have to recreate this object since the consumer is expected to mutate
wantedLockfile
. But maybe that's fairly obvious and isn't worth commenting.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also considering just to save the hash of the object and then comparing hashes. That would use less memory but probably would do more processing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed it. There was actually no need in the copy.