rocky
rocky

Reputation: 7098

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.

Upvotes: 4

Views: 3632

Answers (1)

rocky
rocky

Reputation: 7098

In the end we used patch-package

Upvotes: 10

Related Questions