Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils/link.js')
-rw-r--r--lib/utils/link.js42
1 files changed, 25 insertions, 17 deletions
diff --git a/lib/utils/link.js b/lib/utils/link.js
index 1376f292f..1091f4683 100644
--- a/lib/utils/link.js
+++ b/lib/utils/link.js
@@ -1,13 +1,12 @@
-
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")
+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) {
@@ -27,13 +26,19 @@ function linkIfExists (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
+ 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") {
+ 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
@@ -41,10 +46,13 @@ function link (from, to, gently, abs, cb) {
if (target.length >= from.length) target = from
}
- chain
- ( [ [fs, "stat", from]
- , [rm, to, gently]
- , [mkdir, path.dirname(to)]
- , [fs, "symlink", target, to, "junction"] ]
- , cb)
+ chain(
+ [
+ [fs, 'stat', from],
+ [rm, to, gently],
+ [mkdir, path.dirname(to)],
+ [fs, 'symlink', target, to, 'junction']
+ ],
+ cb
+ )
}