summaryrefslogtreecommitdiff
path: root/deps/npm/lib/utils/warn-deprecated.js
blob: fe5c5ec82a304d42223da5d87796c7ac3b136d9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module.exports = warnDeprecated

var log = require('npmlog')

var deprecations = {}

function warnDeprecated (type) {
  return function warn (messages, instance) {
    if (!instance) {
      if (!deprecations[type]) {
        deprecations[type] = {}
        messages.forEach(function (m) { log.warn(type, m) })
      }
    } else {
      if (!deprecations[type]) deprecations[type] = {}

      if (!deprecations[type][instance]) {
        deprecations[type][instance] = true
        messages.forEach(function (m) { log.warn(type, m) })
      }
    }
  }
}