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 may be applied multiple times

See original GitHub issue

Reduced test case: https://github.com/OliverJAsh/patch-package-multple-patches-bug

If you clone this test case and run yarn multiple times, you’ll find that the patch which adds StreamApiError applies each time yarn is ran, resulting in corrupt code.

patch-package 6.2.2 (latest at time of writing)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:5

github_iconTop GitHub Comments

4reactions
petrbelacommented, Jul 8, 2020

Btw a quick trick to prevent duplication is to make the patch idempotent, i.e. the original code no longer matches the patch after applying the change.

For example, in my case, I changed from:

diff --git a/node_modules/react-native-web/dist/index.js b/node_modules/react-native-web/dist/index.js
index debd306..ca206ec 100644
--- a/node_modules/react-native-web/dist/index.js
+++ b/node_modules/react-native-web/dist/index.js
@@ -71,3 +71,5 @@ export { default as DeviceEventEmitter } from './exports/DeviceEventEmitter'; //
 
 export { default as useColorScheme } from './exports/useColorScheme';
 export { default as useWindowDimensions } from './exports/useWindowDimensions';
+
+export const ViewPropTypes = { style: null }

to

diff --git a/node_modules/react-native-web/dist/index.js b/node_modules/react-native-web/dist/index.js
index debd306..af22832 100644
--- a/node_modules/react-native-web/dist/index.js
+++ b/node_modules/react-native-web/dist/index.js
@@ -70,4 +70,5 @@ export { default as TVEventHandler } from './exports/TVEventHandler'; // plugins
 export { default as DeviceEventEmitter } from './exports/DeviceEventEmitter'; // hooks
 
 export { default as useColorScheme } from './exports/useColorScheme';
+export const ViewPropTypes = { style: null }
 export { default as useWindowDimensions } from './exports/useWindowDimensions';

Since it’s now an insertion instead of an addition, the patch sees the insertion points have changed and doesn’t get applied again.

0reactions
tplkcommented, Nov 6, 2020

Yeah, a comment in the middle did the trick, thanks!

diff --git a/node_modules/@nrwl/jest/src/schematics/jest-project/files/src/test-setup.ts__tmpl__ b/node_modules/@nrwl/jest/src/schematics/jest-project/files/src/test-setup.ts__tmpl__
index ed2d24f..4808e94 100644
--- a/node_modules/@nrwl/jest/src/schematics/jest-project/files/src/test-setup.ts__tmpl__
+++ b/node_modules/@nrwl/jest/src/schematics/jest-project/files/src/test-setup.ts__tmpl__
@@ -1,2 +1,5 @@
+import 'array-flat-polyfill';
 <% if (setupFile === 'angular') { %>import 'jest-preset-angular';
+// matching patch hack
 <% } else if (setupFile === 'web-components') { %>import 'document-register-element';<% } %>
+import 'jsdom-polyfills';
Read more comments on GitHub >

github_iconTop Results From Across the Web

Scopolamine (Transdermal Route) Proper Use - Mayo Clinic
Only one patch should be used at any time. Remove the patch after 3 days. If treatment is to be continued for more...
Read more >
Fentanyl Transdermal Patch: MedlinePlus Drug Information
The patch is usually applied to the skin once every 72 hours. Change your patch at about the same time of day every...
Read more >
Transdermal Patches: How to Apply Them - Healthline
If you're using more than one patch at a time, don't overlap them. And don't place one patch on top of another. The...
Read more >
Buprenorphine for pain: medicine to treat severe pain - NHS
Do not apply more than 1 patch at a time, unless your doctor tells you to. Using more patches than recommended could lead...
Read more >
Prescription Pain Patch: What Is It, Uses, Side Effects
Also known by the brand name Flector, it can be applied near the area of ... and never use more than one patch...
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