Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

monkey patching at the npm package level?

I'd like to extend the npm package "truffle", but currently in version 4 (and version 5), "truffle" doesn't have a plugin extension mechanism.

So the broad question is how to "monkey patch" that. One possiblity would be to list the truffle package as a dependancy and then run some shell commands like "patch" to modify truffle which is generally installed in node_modules.

Does npm have a way where I could run such shell commands after node dependencies are successfuly installed?

Any other suggestions? (Another method might be monkey patching at the nodejs level, but I think that will be more cumbersome.)

EDIT

The postinstall field of scripts in the package.json may be what I am looking for.

like image 767
rocky Avatar asked Oct 23 '25 16:10

rocky


1 Answers

In the end we used patch-package

like image 94
rocky Avatar answered Oct 27 '25 01:10

rocky