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(plugin-commands-patching): leave final newline in patch files #6905

Merged
merged 2 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/orange-years-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@pnpm/patching.apply-patch": patch
"pnpm": patch
---

`pnpm patch` should write patch files with a trailing newline [#6905](https://github.com/pnpm/pnpm/pull/6905).
2 changes: 1 addition & 1 deletion __patches__/graceful-fs@4.2.11.patch
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ index 8d5b89e4fa7fdbaebf58556cc044d2a912bce5de..d09757f19e32ba534453832abb8afe05
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE' || err.code === 'EBUSY'))
enqueue([go$copyFile, [src, dest, flags, cb], err, startTime || Date.now(), Date.now()])
else {
if (typeof cb === 'function')
if (typeof cb === 'function')
3 changes: 2 additions & 1 deletion patching/plugin-commands-patching/src/patchCommit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ async function diffFolders (folderA: string, folderB: string) {
USERPROFILE: '',
// #endregion
},
stripFinalNewline: false,
})
stdout = result.stdout
stderr = result.stderr
Expand All @@ -130,7 +131,7 @@ async function diffFolders (folderA: string, folderB: string) {
.replace(new RegExp(`(a|b)${escapeStringRegexp(`/${removeTrailingAndLeadingSlash(folderBN)}/`)}`, 'g'), '$1/')
.replace(new RegExp(escapeStringRegexp(`${folderAN}/`), 'g'), '')
.replace(new RegExp(escapeStringRegexp(`${folderBN}/`), 'g'), '')
.replace(/\n\\ No newline at end of file$/, '')
.replace(/\n\\ No newline at end of file\n$/, '\n')
}

function removeTrailingAndLeadingSlash (p: string) {
Expand Down
Loading