X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.maps.server%2Fnode%2Fnode-v4.8.0-win-x64%2Fnode_modules%2Fnpm%2Flib%2Futils%2Flink.js;fp=org.simantics.maps.server%2Fnode%2Fnode-v4.8.0-win-x64%2Fnode_modules%2Fnpm%2Flib%2Futils%2Flink.js;h=e353bfae9372a4496e785d325aa588d07fef050d;hb=2529be6d456deeb07c128603ce4971f1dc29b695;hp=0000000000000000000000000000000000000000;hpb=2636fc31c16c23711cf2b06a4ae8537bba9c1d35;p=simantics%2Fdistrict.git diff --git a/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/lib/utils/link.js b/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/lib/utils/link.js new file mode 100644 index 00000000..e353bfae --- /dev/null +++ b/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/lib/utils/link.js @@ -0,0 +1,40 @@ + +module.exports = link +link.ifExists = linkIfExists + +var fs = require("graceful-fs") + , chain = require("slide").chain + , mkdir = require("mkdirp") + , rm = require("./gently-rm.js") + , path = require("path") + , npm = require("../npm.js") + +function linkIfExists (from, to, gently, cb) { + fs.stat(from, function (er) { + if (er) return cb() + link(from, to, gently, cb) + }) +} + +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 target = from = path.resolve(from) + if (!abs && 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", target, to, "junction"] ] + , cb) +}