symlink-dir
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -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>; |
@@ -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
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
10382
103
6
+ Addedis-windows@^1.0.0
+ Added@types/node@7.10.14(transitive)
+ Addedis-windows@1.0.2(transitive)
+ Addedmkdirp-promise@5.0.1(transitive)
- Removed@types/node@6.14.13(transitive)
- Removedmkdirp-promise@3.0.1(transitive)
Updated@types/node@^7.0.4
Updatedmkdirp-promise@^5.0.0