25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 년 전
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. in-publish
  2. ==========
  3. > For background, see [npm#10074](https://github.com/npm/npm/issues/10074).
  4. Detect if we were run as a result of `npm publish`. This is intended to allow you to
  5. easily have prepublish lifecycle scripts that don't run when you run `npm install`.
  6. ```
  7. $ npm install --save-dev in-publish
  8. in-publish@1.0.0 node_modules/in-publish
  9. ```
  10. Then edit your package.json to have:
  11. ```json
  12. "scripts": {
  13. "prepublish": "in-publish && thing-I-dont-want-on-dev-install || not-in-publish"
  14. }
  15. ```
  16. Now when you run:
  17. ```
  18. $ npm install
  19. ```
  20. Then `thing-I-dont-want-on-dev-install` won't be run, but...
  21. ```
  22. $ npm publish
  23. ```
  24. And `thing-I-dont-want-on-dev-install` will be run.
  25. It's worth noting that the `prepublish` lifecycle is _ALSO_ called when you build a tarball, so:
  26. ```
  27. $ npm pack
  28. ```
  29. Will call your `prepublish` lifecycle, but with the example above,
  30. `thing-I-dont-want-on-dev-install` won't be run.
  31. If you want this, you can use another helper included here:
  32. ```json
  33. "scripts": {
  34. "prepublish": "not-in-install && thing-I-dont-want-on-dev-install || in-install"
  35. }
  36. ```
  37. The above will run your `thing-I-dont-want-on-dev-install` on `publish` and
  38. on `pack` but not on `install`.