patch-package icon indicating copy to clipboard operation
patch-package copied to clipboard

the package.json patch doesn't recover in the new package

Open JeanZhao opened this issue 4 years ago • 5 comments

Thanks for your work.

Here I faced two problems.

  1. npx patch-package --exclude '^$' doesn't work for me. Something I got was:

patch-package 6.2.2 • Creating temporary folder • Installing [email protected] with npm • Diffing your files with clean files ⁉️ Not creating patch file for package 'ts-loader' ⁉️ There don't appear to be any changes.

  1. So I tried to exclude some non-existent file,e.g. npx patch-package --exclude 'a.txt'. It got worked(I can see the updated package.json in the patch file) Then, I tried to delete the old package, and do npm install, the package doesn't contain the patch file content. Btw, the script in my root project package.json, I added {"postinstall": "patch-package"}

Is there anything I missed? Please feel free to reproduce this issue with any npm package.

JeanZhao avatar May 20 '20 14:05 JeanZhao

It seems to be working for me, this is what I'm doing:

yarn patch-package rehype-slug --exclude '^$'

Every time that I run yarn, it restores the patch, because of the postinstall script in my package.json:

  "scripts": {
    "postinstall": "patch-package"
  }

karlhorky avatar Aug 26 '21 15:08 karlhorky

Thank you so much @karlhorky By the way, what does the --exclude '^s' means?

umarluqman avatar May 19 '22 01:05 umarluqman

@umarluqman careful, you have an s there, not a dollar sign :)

As far as I can tell, the --exclude '^$' is an option to exclude no files (the ^$ is an empty regular expression, matching no strings)

karlhorky avatar May 19 '22 12:05 karlhorky

@umarluqman to elaborate on what @karlhorky said, here’s regexr’s explanation on what’s going on in that regular expression: image

FlorianWendelborn avatar May 19 '22 14:05 FlorianWendelborn

thank you @FlorianWendelborn and @karlhorky, that makes sense

umarluqman avatar May 20 '22 02:05 umarluqman