summaryrefslogtreecommitdiff
path: root/deps/npm/lib/install/and-add-parent-to-errors.js
blob: fe4128230b1af5633328b31f4fc380191749624b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
'use strict'
var moduleName = require('../utils/module-name.js')
var validate = require('aproba')

module.exports = function (parent, cb) {
  validate('F', [cb])
  return function (er) {
    if (!er) return cb.apply(null, arguments)
    if (er instanceof Error && parent && parent.package && parent.package.name) {
      er.parent = moduleName(parent)
    }
    cb(er)
  }
}