Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

symlink-or-copy

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

symlink-or-copy - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

5

CHANGELOG.md
# 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 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc