prepare.js 1.0 KB

123456789101112131415161718192021222324252627
  1. 'use strict'
  2. var chain = require('slide').chain
  3. var lifecycle = require('../../utils/lifecycle.js')
  4. var packageId = require('../../utils/package-id.js')
  5. var prepublishWarning = require('../../utils/warn-deprecated.js')('prepublish-on-install')
  6. var moduleStagingPath = require('../module-staging-path.js')
  7. module.exports = function (staging, pkg, log, next) {
  8. log.silly('prepublish', packageId(pkg))
  9. // TODO: for `npm@5`, change the behavior and remove this warning.
  10. // see https://github.com/npm/npm/issues/10074 for details
  11. if (pkg.package && pkg.package.scripts && pkg.package.scripts.prepublish) {
  12. prepublishWarning([
  13. 'As of npm@5, `prepublish` scripts are deprecated.',
  14. 'Use `prepare` for build steps and `prepublishOnly` for upload-only.',
  15. 'See the deprecation note in `npm help scripts` for more information.'
  16. ])
  17. }
  18. var buildpath = moduleStagingPath(staging, pkg)
  19. chain(
  20. [
  21. [lifecycle, pkg.package, 'prepublish', buildpath],
  22. [lifecycle, pkg.package, 'prepare', buildpath]
  23. ],
  24. next
  25. )
  26. }