Comparing version 2.1.2 to 2.1.3
@@ -21,2 +21,3 @@ // if the thing isn't there, skip it | ||
const SKIP = Symbol('skip - missing or already installed') | ||
const CLOBBER = Symbol('clobber - ours or in forceful mode') | ||
@@ -39,3 +40,3 @@ const linkGently = ({path, to, from, absFrom, force}) => { | ||
if (!stTo.isSymbolicLink()) | ||
return force ? rm(to) : Promise.resolve() | ||
return force && rm(to).then(() => CLOBBER) | ||
@@ -48,3 +49,3 @@ return readlink(to).then(target => { | ||
if (target.indexOf(path) === 0 || force) | ||
return rm(to) | ||
return rm(to).then(() => CLOBBER) | ||
}) | ||
@@ -56,6 +57,13 @@ } else { | ||
}) | ||
// this will fail if we didn't remove it | ||
.then(skip => skip !== SKIP && symlink(from, to, 'file').then(() => true)) | ||
.then(skipOrClobber => { | ||
if (skipOrClobber === SKIP) | ||
return true | ||
return symlink(from, to, 'file').catch(er => { | ||
if (skipOrClobber === CLOBBER || force) | ||
return rm(to).then(() => symlink(from, to, 'file')) | ||
throw er | ||
}).then(() => true) | ||
}) | ||
} | ||
module.exports = linkGently |
{ | ||
"name": "bin-links", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "JavaScript package binary linker", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18398
322