symlink-or-copy
Advanced tools
Comparing version 1.1.0 to 1.1.1
# master | ||
# 1.1.1 | ||
* [BUGFIX] use realpath before creating a junction to ensure we always point to | ||
the concrete source, not another junction. | ||
# 1.1.0 | ||
@@ -4,0 +9,0 @@ |
23
index.js
@@ -83,15 +83,22 @@ var fs = require('fs') | ||
function symlinkWindows(srcPath, destPath) { | ||
var stat = options.fs.statSync(srcPath) | ||
var stat = options.fs.lstatSync(srcPath) | ||
var isDir = stat.isDirectory() | ||
var wasResolved = false; | ||
if (stat.isSymbolicLink()) { | ||
src = options.fs.realpathSync(srcPath); | ||
isDir = options.fs.lstatSync(srcPath).isDirectory(); | ||
wasResolved = true; | ||
} | ||
if (options.canSymlink) { | ||
srcPath = options.fs.realpathSync(srcPath) | ||
options.fs.symlinkSync(srcPath, destPath, isDir ? 'dir' : 'file') | ||
} else if (isDir) { | ||
srcPath = options.fs.realpathSync(srcPath) | ||
options.fs.symlinkSync(srcPath, destPath, 'junction'); | ||
options.fs.symlinkSync(wasResolved ? srcPath : path.resolve(srcPath), destPath, isDir ? 'dir' : 'file') | ||
} else { | ||
options.fs.writeFileSync(destPath, options.fs.readFileSync(srcPath), { flag: 'wx', mode: stat.mode }) | ||
options.fs.utimesSync(destPath, stat.atime, stat.mtime) | ||
if (isDir) { | ||
options.fs.symlinkSync(wasResolved ? srcPath : path.resolve(srcPath), destPath, 'junction'); | ||
} else { | ||
options.fs.writeFileSync(destPath, options.fs.readFileSync(srcPath), { flag: 'wx', mode: stat.mode }) | ||
options.fs.utimesSync(destPath, stat.atime, stat.mtime) | ||
} | ||
} | ||
} |
{ | ||
"name": "symlink-or-copy", | ||
"description": "Symlink files or directories, falling back to copying on Windows", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"author": "Jo Liss <joliss42@gmail.com>", | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
@@ -11,3 +11,3 @@ var assert = require('assert'); | ||
var count = 0; | ||
var lsStatSyncCount = 0; | ||
var lstatSyncCount = 0; | ||
var isDirectoryCount = 0; | ||
@@ -21,4 +21,4 @@ symLinkOrCopy.setOptions({ | ||
fs: { | ||
statSync: function() { | ||
lsStatSyncCount++; | ||
lstatSync: function() { | ||
lstatSyncCount++; | ||
return { | ||
@@ -40,4 +40,4 @@ isSymbolicLink: function() { | ||
assert.equal(count, 2); | ||
assert.equal(lsStatSyncCount, 1); | ||
assert.equal(isDirectoryCount, 1); | ||
assert.equal(lstatSyncCount, 2); | ||
assert.equal(isDirectoryCount, 2); | ||
}); | ||
@@ -48,3 +48,3 @@ | ||
var count = 0 | ||
var lsStatSyncCount = 0 | ||
var lstatSyncCount = 0 | ||
var isDirectoryCount = 0 | ||
@@ -61,4 +61,4 @@ var readFileSyncCount = 0 | ||
fs: { | ||
statSync: function() { | ||
lsStatSyncCount++ | ||
lstatSync: function() { | ||
lstatSyncCount++ | ||
return { | ||
@@ -89,5 +89,5 @@ isSymbolicLink: function() { | ||
symLinkOrCopy.sync('foo', 'bar'); | ||
assert.equal(count, 0); | ||
assert.equal(lsStatSyncCount, 1); | ||
assert.equal(isDirectoryCount, 1); | ||
assert.equal(count, 1); | ||
assert.equal(lstatSyncCount, 2); | ||
assert.equal(isDirectoryCount, 2); | ||
assert.equal(writeFileSyncCount, 1); | ||
@@ -102,3 +102,3 @@ assert.equal(readFileSyncCount, 1); | ||
fs: { | ||
statSync: function() { | ||
lstatSync: function() { | ||
return { | ||
@@ -121,3 +121,3 @@ isSymbolicLink: function() { | ||
symLinkOrCopy.sync(); | ||
assert.equal(count, 2); | ||
assert.equal(count, 3); | ||
}) | ||
@@ -124,0 +124,0 @@ }); |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
11552
225
0