README.md~ 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. in-publish
  2. ==========
  3. Detect if we were run as a result of `npm publish`. This is intended to allow you to
  4. easily have prepublish lifecycle scripts that don't run when you run `npm install`.
  5. ```
  6. $ npm install --save in-publish
  7. in-publish@1.0.0 node_modules/in-publish
  8. ```
  9. Then edit your package.json to have:
  10. ```json
  11. "scripts": {
  12. "prepublish": "in-publish && thing-I-dont-want-on-dev-install || in-install"
  13. }
  14. ```
  15. Now when you run:
  16. ```
  17. $ npm install
  18. ```
  19. Then `thing-I-dont-want-on-dev-install` won't be run, but...
  20. ```
  21. $ npm publish
  22. ```
  23. And `thing-I-dont-want-on-dev-install` will be run.
  24. Caveat Emptor
  25. =============
  26. This detects that its running as a part of publish command in a terrible,
  27. terrible way. NPM dumps out its config object blindly into the environment
  28. prior to running commands. This includes the command line it was invoked
  29. with. This module determines if its being run as a result of publish by
  30. looking at that env var. This is not a part of the documented npm interface
  31. and so it is not guarenteed to be stable.