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

If patch failed, the process should exit with an error. #159

Closed
aabuhijleh opened this issue Jul 25, 2019 · 8 comments · Fixed by #168
Closed

If patch failed, the process should exit with an error. #159

aabuhijleh opened this issue Jul 25, 2019 · 8 comments · Fixed by #168

Comments

@aabuhijleh
Copy link

Right now, if patching a package fails for some reason, for example, if file to be patched is not found, a warning is printed on the terminal and the process continues.

Warning: Patch file found for package **package-name** which is not present at ...

This is potentially dangerous and could break things in an application.

I propose that this is not enough and that the process should be exited and not allowed to complete execution and an error should be clearly indicated.

@KonstaL
Copy link

KonstaL commented Aug 8, 2019

+1
This just caused some problems with our production build.
If defaulting a an error is too much, the error level should be configurable through a flag.

For example:
patch-package --fail-on-warning

@johansedgeware
Copy link

Definitely +1 on this. Had similar problem as KonstaL

@Slessi
Copy link

Slessi commented Sep 11, 2019

@ds300 unfortunately this causes a new problem for me when I have a patch for a package in devDependencies and later run yarn --production

the patch fails due to module not being present, which is expected for me as im trying to install production modules only

@ds300
Copy link
Owner

ds300 commented Sep 11, 2019

Ah, I'm very sorry about that @Slessi I'm working on a fix!

@ds300
Copy link
Owner

ds300 commented Sep 11, 2019

Ok @Slessi I pushed a fix to v6.2.0 you probably don't need to do anything except upgrade but read this just in case: https://github.com/ds300/patch-package#dev-only-patches

@Boxonical
Copy link

Boxonical commented Sep 12, 2019

Hi, I'm running microservices, all the services shared a "patches" folder.
ie. list of patches

  1. datapumps
  2. loopback-connector-mongodb
  3. modem

If file to be patched is not found:
Expected behavior - The process continues.
Current behavior - The process exits. (if patch no.2 not found, only patch no.1 is applied)

Whether the process exits or not, should this be a flag (ie. --fail-on-warning) instead ?

@ds300
Copy link
Owner

ds300 commented Sep 12, 2019

@Boxonical Thanks for letting me know. The behaviour you're relying on is dangerous, as described above. So I don't want to support it going forward. I'm very sorry for the breaking change :/

The easiest solution for you right now is probably to make separate patch folders for each microservice which copies or symlinks only the required patch files for that service. Let me know if I can be of any more help 🙏

From now on sharing patch files between different projects should be easiest the same way we share node_modules between different projects, i.e. using yarn workspaces. This works really nicely.

@JackCA
Copy link

JackCA commented Oct 23, 2019

I also would love an option to ignore these errors.

I'm doing docker-based yarn workspace microservice deploys where some packages that are patched may not exist.

But I've added the ones to be ignored to my .dockerignore, so that's another option besides symlinking if you're doing something docker-based.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants