warn-deprecated.js 556 B

1234567891011121314151617181920212223
  1. module.exports = warnDeprecated
  2. var log = require('npmlog')
  3. var deprecations = {}
  4. function warnDeprecated (type) {
  5. return function warn (messages, instance) {
  6. if (!instance) {
  7. if (!deprecations[type]) {
  8. deprecations[type] = {}
  9. messages.forEach(function (m) { log.warn(type, m) })
  10. }
  11. } else {
  12. if (!deprecations[type]) deprecations[type] = {}
  13. if (!deprecations[type][instance]) {
  14. deprecations[type][instance] = true
  15. messages.forEach(function (m) { log.warn(type, m) })
  16. }
  17. }
  18. }
  19. }