Skip to content

Commit

Permalink
fix(plugin-commands-patching): leave final newline in patch files (#6905
Browse files Browse the repository at this point in the history
)

The safe-execa library strips the final newline from the command
output by default.  Here it should be left in.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
  • Loading branch information
andersk committed Aug 17, 2023
1 parent 3ecdab9 commit 512d712
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 50 deletions.
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

0 comments on commit 512d712

Please sign in to comment.