postinstall-postinstall
postinstall-postinstall copied to clipboard
Running the postinstall hook twice is surprising and unexpected, especially with suppressed output
As noted in the README, this package runs the postinstall hook twice when yarn is run on your project.
The first time it is run, apparently standard out and standard in are swallowed. This is no doubt done to prevent confusion on the part of users of patch-package
, so they don't see reports of their patches being run twice.
However, I needed to add another script to my postinstall hook cause I needed to do patching in a different way than patch-package
does. My script happened to be idempotent, but I spent hours tearing my hair out because it was reporting that my patch had already been applied. How could the script be getting run twice? But it couldn't be getting run twice because if it were, it would be reporting both runs on the console, WOULDN'T IT???????
Finally I got to the README in this package. I had read the README of patch-package
, but hadn't bothered coming here.
I suggest that, if a better way cannot be found to convince yarn to run the postinstall hook on yarn remove
, that a note warning of this behavior should be added to the Why use postinstall-postinstall section of the patch-package
README.
Also, add a note to the fact that standard out and standard error are suppressed to this README.