package: add a postinstall script when lib is distributed via git
Right now, the lib/defs.js generated file is only available on packages published on NPM because it is generated during the prepare phase of the NPM packaging step.
By adding a postinstall step we make sure the file is also generated by other publishing means (be it local package path or git path for instance).
This additional postinstall hook could seem “dangerous” at first glance however:
- if the
lib/defs.jsfile is already present, thenmakewon't do anything. - if
npm installis ran in “production” mode (be it with--productionorNODE_ENV=production) in a project including this lib (amqplib), thedevDependenciesof the lib will get installed and thepostinstallhook will work as expected. (At least that's what happened on Debian OS)
If you have a better idea on how the lib/defs.js can be generated in case the lib is used via git / http (instead of npm registry) please let me know, I'd be very much interested.
Thanks!
What if the OS doesn't have make installed?
The plan is to commit lib/defs.js