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