question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

patch-package should support patching itself in `postinstall` script

See original GitHub issue

patch-package is great, so much so that I recently found myself attempting to use it to patch patch-package itself as I came across issue #201. It didn’t work, at least in my setup, using "postinstall": "patch-package" in the package.json file. What I think was happening is that by the time patch-package had patched itself, it was too late – the old unpatched code was already being used to patch other packages.

Perhaps the solution might be for patch-package to detect if one of the patch files is for patch-package itself, and if so, apply that patch first, then re-exec itself before continuing with other patches. (When re-exec’ing, perhaps add a command-line option like --no-self-patch to prevent patching itself in a loop.) 😃

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pdcastrocommented, Apr 23, 2020

@mikehardy, great suggestion! I wasn’t aware of the --patch-dir option: it is not documented by npx patch-package --help, but indeed it is in the source code. I’ve successfully “solved” issue #201 in my project thanks to your tip. 👍

0reactions
mikehardycommented, Apr 23, 2020

Mine all mine, precious internet points https://github.com/ds300/patch-package/pull/225 Cheers 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Super Easy NPM Package Patching with 'patch-package'
How to use. To use patch-package, make your changes right in the package code in node_modules and run patch-package . That's it! It'll...
Read more >
The easiest way to patch your npm package when there is a
The easiest way and actually most devs do, is go to Github's package repository and log a bug. The real problem with that...
Read more >
patch-package - npm
patch -package lets app authors instantly make and keep fixes to npm dependencies. It's a vital band-aid for those of us living on...
Read more >
Not able to include package.json in the patch #49 - GitHub
TL,DR: What would be the way to include package.json in the patch? ... yarn.lock anyway :( It makes sense, as it run a...
Read more >
patch-package in React Native - Anu Thomas - Medium
If we are running patch-package without any arguments, it will apply all patches in your project. We can give options also. The options...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found