aboutsummaryrefslogtreecommitdiff
path: root/deps/node/deps/npm/lib/install/action/prepare.js
blob: d48c8e7e86249a80d92e9dcdacb23d7e8f4af3cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict'
var chain = require('slide').chain
var lifecycle = require('../../utils/lifecycle.js')
var packageId = require('../../utils/package-id.js')
var prepublishWarning = require('../../utils/warn-deprecated.js')('prepublish-on-install')
var moduleStagingPath = require('../module-staging-path.js')

module.exports = function (staging, pkg, log, next) {
  log.silly('prepublish', packageId(pkg))
  // TODO: for `npm@5`, change the behavior and remove this warning.
  // see https://github.com/npm/npm/issues/10074 for details
  if (pkg.package && pkg.package.scripts && pkg.package.scripts.prepublish) {
    prepublishWarning([
      'As of npm@5, `prepublish` scripts are deprecated.',
      'Use `prepare` for build steps and `prepublishOnly` for upload-only.',
      'See the deprecation note in `npm help scripts` for more information.'
    ])
  }
  var buildpath = moduleStagingPath(staging, pkg)
  chain(
    [
      [lifecycle, pkg.package, 'prepublish', buildpath],
      [lifecycle, pkg.package, 'prepare', buildpath]
    ],
    next
  )
}