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 1.0.0 to 1.0.1

5

dist/index.d.ts

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

/**
* Relative symlink
*/
export default function relSymlink(src: string, dest: string): Promise<void>;
export default function symlinkDir(src: string, dest: string): Promise<void>;

42

dist/index.js

@@ -10,18 +10,17 @@ "use strict";

};
const forceSymlink_1 = require("./forceSymlink");
const fs = require("mz/fs");
const path = require("path");
const os = require("os");
const mkdirp = require("mkdirp-promise/lib/node4");
const mkdirp = require("mkdirp-promise");
const isWindows = require("is-windows");
// Always use "junctions" on Windows. Even though support for "symbolic links" was added in Vista+, users by default
// lack permission to create them
const symlinkType = os.platform() === 'win32' ? 'junction' : 'dir';
/**
* Relative symlink
*/
function relSymlink(src, dest) {
const symlinkType = isWindows() ? 'junction' : 'dir';
function symlinkDir(src, dest) {
return __awaiter(this, void 0, void 0, function* () {
src = path.resolve(src);
dest = path.resolve(dest);
// Junction points can't be relative
const rel = symlinkType !== 'junction' ? path.relative(path.dirname(dest), src) : src;
try {
yield forceSymlink_1.default(rel, dest, symlinkType);
yield forceSymlink(rel, dest);
}

@@ -31,3 +30,3 @@ catch (err) {

yield mkdirp(path.dirname(dest));
yield forceSymlink_1.default(rel, dest, symlinkType);
yield forceSymlink(rel, dest);
return;

@@ -40,3 +39,24 @@ }

Object.defineProperty(exports, "__esModule", { value: true });
exports.default = relSymlink;
exports.default = symlinkDir;
/**
* Creates a symlink. Re-link if a symlink already exists at the supplied
* srcPath. API compatible with [`fs#symlink`](https://nodejs.org/api/fs.html#fs_fs_symlink_srcpath_dstpath_type_callback).
*/
function forceSymlink(src, dest) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield fs.symlink(src, dest, symlinkType);
}
catch (err) {
if (err.code !== 'EEXIST')
throw err;
const linkString = yield fs.readlink(dest);
if (src === linkString) {
return;
}
yield fs.unlink(dest);
yield forceSymlink(src, dest);
}
});
}
//# sourceMappingURL=index.js.map
{
"name": "symlink-dir",
"version": "1.0.0",
"version": "1.0.1",
"description": "Cross-platform directory symlinking",

@@ -47,5 +47,6 @@ "main": "dist/index.js",

"@types/mz": "0.0.30",
"@types/node": "^6.0.45",
"@types/node": "^7.0.4",
"is-windows": "^1.0.0",
"mkdirp": "^0.5.1",
"mkdirp-promise": "^3.0.1",
"mkdirp-promise": "^5.0.0",
"mz": "^2.4.0"

@@ -52,0 +53,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