Permalink
Browse files

Fix #2572 Make bin symlinks relative on Unix

  • Loading branch information...
1 parent 52c2e25 commit df97de6903322b52703a07faaf4e9f6c72dbf021 @isaacs isaacs committed Jun 27, 2012
Showing with 11 additions and 1 deletion.
  1. +11 −1 lib/utils/link.js
View
@@ -20,10 +20,20 @@ function link (from, to, gently, cb) {
if (typeof cb !== "function") cb = gently, gently = null
if (npm.config.get("force")) gently = false
+ to = path.resolve(to)
+ var target = from = path.resolve(from)
+ if (process.platform !== "win32") {
+ // junctions on windows must be absolute
+ target = path.relative(path.dirname(to), from)
+ // if there is no folder in common, then it will be much
+ // longer, and using a relative link is dumb.
+ if (target.length >= from.length) target = from
+ }
+
chain
( [ [fs, "stat", from]
, [rm, to, gently]
, [mkdir, path.dirname(to)]
- , [fs, "symlink", from, to, "junction"] ]
+ , [fs, "symlink", target, to, "junction"] ]
, cb)
}

0 comments on commit df97de6

Please sign in to comment.