Socket
Socket
Sign inDemoInstall

symlink-dir

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

symlink-dir - npm Package Compare versions

Comparing version 5.0.1 to 5.0.2

4

dist/index.d.ts

@@ -1,2 +0,4 @@

declare function symlinkDir(src: string, dest: string): Promise<{
declare function symlinkDir(src: string, dest: string, opts?: {
overwrite?: boolean;
}): Promise<{
reused: Boolean;

@@ -3,0 +5,0 @@ warn?: string;

@@ -17,3 +17,3 @@ "use strict";

}
function symlinkDir(src, dest) {
function symlinkDir(src, dest, opts) {
dest = betterPathResolve(dest);

@@ -24,3 +24,3 @@ src = betterPathResolve(src);

src = resolveSrc(src, dest);
return forceSymlink(src, dest);
return forceSymlink(src, dest, opts);
}

@@ -31,3 +31,3 @@ /**

*/
async function forceSymlink(src, dest) {
async function forceSymlink(src, dest, opts) {
try {

@@ -49,6 +49,9 @@ await fs_1.promises.symlink(src, dest, symlinkType);

}
await forceSymlink(src, dest);
await forceSymlink(src, dest, opts);
return { reused: false };
case 'EEXIST':
case 'EISDIR':
if ((opts === null || opts === void 0 ? void 0 : opts.overwrite) === false) {
throw err;
}
// If the target file already exists then we proceed.

@@ -68,7 +71,17 @@ // Additional checks are done below.

const parentDir = path.dirname(dest);
const ignore = `.ignored_${path.basename(dest)}`;
await renameOverwrite(dest, path.join(parentDir, ignore));
let warn;
if (opts === null || opts === void 0 ? void 0 : opts.renameTried) {
// This is needed in order to fix a mysterious bug that sometimes happens on macOS.
// It is hard to reproduce and is described here: https://github.com/pnpm/pnpm/issues/5909#issuecomment-1400066890
await fs_1.promises.unlink(dest);
warn = `Symlink wanted name was occupied by directory or file. Old entity removed: "${parentDir}${path.sep}{${path.basename(dest)}".`;
}
else {
const ignore = `.ignored_${path.basename(dest)}`;
await renameOverwrite(dest, path.join(parentDir, ignore));
warn = `Symlink wanted name was occupied by directory or file. Old entity moved: "${parentDir}${path.sep}{${path.basename(dest)} => ${ignore}".`;
}
return {
...await forceSymlink(src, dest),
warn: `Symlink wanted name was occupied by directory or file. Old entity moved: "${parentDir}${path.sep}{${path.basename(dest)} => ${ignore}}".`,
...await forceSymlink(src, dest, { ...opts, renameTried: true }),
warn,
};

@@ -80,3 +93,3 @@ }

await fs_1.promises.unlink(dest);
return await forceSymlink(src, dest);
return await forceSymlink(src, dest, opts);
}

@@ -83,0 +96,0 @@ // for backward compatibility

{
"name": "symlink-dir",
"version": "5.0.1",
"description": "Cross-platform directory symlinking",
"main": "dist/index.js",
"files": [
"dist/",
"!*.map"
],
"typings": "dist/index.d.ts",
"bin": "dist/cli.js",
"keywords": [
"symlink",
"symlinking",
"junction",
"directory",
"dir",
"folder"
],
"repository": {
"type": "git",
"url": "git+https://github.com/zkochan/symlink-dir.git"
},
"author": {
"name": "Zoltan Kochan",
"email": "z@kochan.io",
"url": "https://www.kochan.io"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/zkochan/symlink-dir/issues"
},
"homepage": "https://github.com/zkochan/symlink-dir#readme",
"devDependencies": {
"@types/node": "^14.0.11",
"@types/tape": "^4.13.0",
"mos": "^1.3.1",
"mos-plugin-readme": "^1.0.4",
"rimraf": "^3.0.2",
"tape": "^5.0.1",
"tempy": "^1.0.0",
"ts-node": "^9.0.0",
"typescript": "^4.0.0",
"write-json-file": "^4.3.0"
},
"dependencies": {
"better-path-resolve": "^1.0.0",
"rename-overwrite": "^4.0.0"
},
"mos": {
"plugins": [
"readme"
],
"installation": {
"useShortAlias": true
}
},
"engines": {
"node": ">=12.10"
},
"scripts": {
"pretest": "rimraf node_modules/src",
"test": "ts-node test",
"test-md": "mos t",
"premd": "rimraf node_modules/src && npm run tsc",
"md": "mos",
"tsc": "rimraf dist && tsc"
}
}
"name": "symlink-dir",
"version": "5.0.2",
"description": "Cross-platform directory symlinking",
"main": "dist/index.js",
"files": [
"dist/",
"!*.map"
],
"typings": "dist/index.d.ts",
"bin": "dist/cli.js",
"keywords": [
"symlink",
"symlinking",
"junction",
"directory",
"dir",
"folder"
],
"repository": {
"type": "git",
"url": "git+https://github.com/pnpm/symlink-dir.git"
},
"author": {
"name": "Zoltan Kochan",
"email": "z@kochan.io",
"url": "https://www.kochan.io"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/pnpm/symlink-dir/issues"
},
"homepage": "https://github.com/pnpm/symlink-dir#readme",
"devDependencies": {
"@types/node": "^16.18.3",
"@types/tape": "^4.13.2",
"rimraf": "^3.0.2",
"tape": "^5.6.1",
"tempy": "^1.0.1",
"ts-node": "^10.9.1",
"typescript": "^4.9.3",
"write-json-file": "^4.3.0"
},
"dependencies": {
"better-path-resolve": "^1.0.0",
"rename-overwrite": "^4.0.3"
},
"mos": {
"plugins": [
"readme"
],
"installation": {
"useShortAlias": true
}
},
"engines": {
"node": ">=12.10"
},
"scripts": {
"pretest": "rimraf node_modules/src",
"test": "ts-node test",
"premd": "rimraf node_modules/src && npm run tsc",
"tsc": "rimraf dist && tsc"
}
}

@@ -5,4 +5,4 @@ # symlink-dir

<!--@shields('npm', 'travis', 'appveyor')-->
[![npm version](https://img.shields.io/npm/v/symlink-dir.svg)](https://www.npmjs.com/package/symlink-dir) [![Build Status](https://img.shields.io/travis/zkochan/symlink-dir/master.svg)](https://travis-ci.org/zkochan/symlink-dir) [![Build Status on Windows](https://img.shields.io/appveyor/ci/zkochan/symlink-dir/master.svg)](https://ci.appveyor.com/project/zkochan/symlink-dir/branch/master)
<!--@shields('npm')-->
[![npm version](https://img.shields.io/npm/v/symlink-dir.svg)](https://www.npmjs.com/package/symlink-dir)
<!--/@-->

@@ -53,6 +53,10 @@

### `symlinkDir(src, dest): Promise<{ reused: boolean, warn?: string }>`
### `symlinkDir(src, dest, opts?): Promise<{ reused: boolean, warn?: string }>`
Creates a symlink in `dest` that points to `src`.
Options:
* `overwrite` - *boolean* - is `true` by default. When `false`, existing files at dest are not overwritten.
Result:

@@ -59,0 +63,0 @@

Sorry, the diff of this file is not supported yet

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