New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pnpm/fs.hard-link-dir

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pnpm/fs.hard-link-dir - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

33

lib/index.js

@@ -20,6 +20,6 @@ "use strict";

if ((await fs_1.promises.lstat(srcFile)).isDirectory()) {
await Promise.all(destDirs.map(async (destDir) => {
const destFile = path_1.default.join(destDir, file);
const destSubdirs = await Promise.all(destDirs.map(async (destDir) => {
const destSubdir = path_1.default.join(destDir, file);
try {
await fs_1.promises.mkdir(destFile, { recursive: true });
await fs_1.promises.mkdir(destSubdir, { recursive: true });
}

@@ -30,4 +30,5 @@ catch (err) { // eslint-disable-line

}
return hardLinkDir(srcFile, [destFile]);
return destSubdir;
}));
await hardLinkDir(srcFile, destSubdirs);
return;

@@ -38,13 +39,10 @@ }

try {
await linkOrCopy(srcFile, destFile);
await linkOrCopyFile(srcFile, destFile);
}
catch (err) { // eslint-disable-line
if (err.code === 'ENOENT') {
await fs_1.promises.mkdir(destDir, { recursive: true });
await linkOrCopy(srcFile, destFile);
// Ignore broken symlinks
return;
}
if (err.code !== 'EEXIST') {
throw err;
}
throw err;
}

@@ -55,2 +53,17 @@ }));

exports.hardLinkDir = hardLinkDir;
async function linkOrCopyFile(srcFile, destFile) {
try {
await linkOrCopy(srcFile, destFile);
}
catch (err) { // eslint-disable-line
if (err.code === 'ENOENT') {
await fs_1.promises.mkdir(path_1.default.dirname(destFile), { recursive: true });
await linkOrCopy(srcFile, destFile);
return;
}
if (err.code !== 'EEXIST') {
throw err;
}
}
}
/*

@@ -57,0 +70,0 @@ * This function could be optimized because we don't really need to try linking again

{
"name": "@pnpm/fs.hard-link-dir",
"version": "1.0.2",
"version": "1.0.3",
"description": "Hard link (or copy if linking fails) all files from a directory to several target directories.",

@@ -28,3 +28,3 @@ "main": "lib/index.js",

"devDependencies": {
"@pnpm/fs.hard-link-dir": "1.0.2",
"@pnpm/fs.hard-link-dir": "1.0.3",
"@pnpm/prepare": "0.0.62"

@@ -31,0 +31,0 @@ },

Sorry, the diff of this file is not supported yet

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