PATH:
opt
/
alt
/
alt-nodejs6
/
root
/
usr
/
lib
/
node_modules
/
npm
/
lib
/
utils
module.exports = link link.ifExists = linkIfExists var fs = require('graceful-fs') var chain = require('slide').chain var mkdir = require('mkdirp') var rm = require('./gently-rm.js') var path = require('path') var npm = require('../npm.js') function linkIfExists (from, to, gently, cb) { fs.stat(from, function (er) { if (er) return cb() fs.readlink(to, function (er, fromOnDisk) { // if the link already exists and matches what we would do, // we don't need to do anything if (!er) { var toDir = path.dirname(to) var absoluteFrom = path.resolve(toDir, from) var absoluteFromOnDisk = path.resolve(toDir, fromOnDisk) if (absoluteFrom === absoluteFromOnDisk) return cb() } link(from, to, gently, cb) }) }) } function resolveIfSymlink (maybeSymlinkPath, cb) { fs.lstat(maybeSymlinkPath, function (err, stat) { if (err) return cb.apply(this, arguments) if (!stat.isSymbolicLink()) return cb(null, maybeSymlinkPath) fs.readlink(maybeSymlinkPath, cb) }) } function ensureFromIsNotSource (from, to, cb) { resolveIfSymlink(from, function (err, fromDestination) { if (err) return cb.apply(this, arguments) if (path.resolve(path.dirname(from), fromDestination) === path.resolve(to)) { return cb(new Error('Link target resolves to the same directory as link source: ' + to)) } cb.apply(this, arguments) }) } function link (from, to, gently, abs, cb) { if (typeof cb !== 'function') { cb = abs abs = false } if (typeof cb !== 'function') { cb = gently gently = null } if (npm.config.get('force')) gently = false to = path.resolve(to) var toDir = path.dirname(to) var absTarget = path.resolve(toDir, from) var relativeTarget = path.relative(toDir, absTarget) var target = abs ? absTarget : relativeTarget chain( [ [ensureFromIsNotSource, absTarget, to], [fs, 'stat', absTarget], [rm, to, gently], [mkdir, path.dirname(to)], [fs, 'symlink', target, to, 'junction'] ], cb ) }
[-] git.js
[edit]
[-] read-local-package.js
[edit]
[-] spawn.js
[edit]
[-] error-message.js
[edit]
[-] is-windows-shell.js
[edit]
[-] get-publish-config.js
[edit]
[-] deep-sort-object.js
[edit]
[-] parse-json.js
[edit]
[-] error-handler.js
[edit]
[-] usage.js
[edit]
[-] link.js
[edit]
[-] map-to-registry.js
[edit]
[-] is-windows-bash.js
[edit]
[-] pulse-till-done.js
[edit]
[-] completion.sh
[edit]
[-] package-id.js
[edit]
[-] no-progress-while-running.js
[edit]
[+]
completion
[-] output.js
[edit]
[-] warn-deprecated.js
[edit]
[-] child-path.js
[edit]
[-] escape-arg.js
[edit]
[-] depr-check.js
[edit]
[-] correct-mkdir.js
[edit]
[-] save-stack.js
[edit]
[-] gently-rm.js
[edit]
[-] tar.js
[edit]
[-] is-windows.js
[edit]
[-] lifecycle.js
[edit]
[+]
..
[-] locker.js
[edit]
[-] rename.js
[edit]
[-] umask.js
[edit]
[-] temp-filename.js
[edit]
[-] module-name.js
[edit]
[-] escape-exec-path.js
[edit]