summaryrefslogtreecommitdiff
path: root/deps/npm/lib/utils
diff options
context:
space:
mode:
authorKat Marchán <kzm@sykosomatic.org>2016-04-11 11:32:13 -0700
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2016-04-14 12:22:16 -0400
commit40e79b1305fb7b0f27278475c8d9ca60d1d5e9b4 (patch)
treeab47dc63a075962f1a9763bb94a485f9cb3563e7 /deps/npm/lib/utils
parenta432935211210bf1c92d057c455a5dd6aa5517ab (diff)
downloadandroid-node-v8-40e79b1305fb7b0f27278475c8d9ca60d1d5e9b4.tar.gz
android-node-v8-40e79b1305fb7b0f27278475c8d9ca60d1d5e9b4.tar.bz2
android-node-v8-40e79b1305fb7b0f27278475c8d9ca60d1d5e9b4.zip
deps: upgrade npm to 3.8.6
PR-URL: https://github.com/nodejs/node/pull/6153 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'deps/npm/lib/utils')
-rw-r--r--deps/npm/lib/utils/link.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/deps/npm/lib/utils/link.js b/deps/npm/lib/utils/link.js
index 1091f46833..d0492e076f 100644
--- a/deps/npm/lib/utils/link.js
+++ b/deps/npm/lib/utils/link.js
@@ -25,6 +25,24 @@ function linkIfExists (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
@@ -48,6 +66,7 @@ function link (from, to, gently, abs, cb) {
chain(
[
+ [ensureFromIsNotSource, from, to],
[fs, 'stat', from],
[rm, to, gently],
[mkdir, path.dirname(to)],