/** * This code is copied from page: * https://github.com/isaacs/npm/blob/master/lib/install.js * * Modified by unclechu for demonstration tabs with spaces coding: * http://unclechumind.blogspot.com/2012/08/blog-post.html */ function localLink (target, where, context, cb) { log.verbose("localLink", target._id) var jsonFile = path.resolve( npm.globalDir, target.name , "package.json" ) , parent = context.parent readJson(jsonFile, function (er, data) { if (er || data._id === target._id) { if (er) { install( path.resolve(npm.globalDir, "..") , target._id , function (er) { if (er) return cb(er, []) thenLink() } ) } else thenLink() function thenLink () { npm.commands.link([target.name], function (er, d) { log.silly("localLink", "back from link", [er, d]) cb(er, [resultList(target, where, parent && parent._id)]) }) } } else { log.verbose("localLink", "install locally (no link)", target._id) installOne_(target, where, context, cb) } }) }