mirror of
https://github.com/shelljs/shelljs.git
synced 2026-01-18 16:03:37 +00:00
Check that source exists for hard links
This commit is contained in:
parent
fd27d85317
commit
39ab73ff61
10
src/ln.js
10
src/ln.js
@ -33,10 +33,6 @@ function _ln(options, source, dest) {
|
||||
var isAbsolute = (path.resolve(source) === sourcePath);
|
||||
dest = path.resolve(process.cwd(), String(dest));
|
||||
|
||||
if ((isAbsolute && !fs.existsSync(sourcePath)) || !fs.existsSync(path.resolve(process.cwd(), path.dirname(dest), source))) {
|
||||
common.error('Source file does not exist', true);
|
||||
}
|
||||
|
||||
if (fs.existsSync(dest)) {
|
||||
if (!options.force) {
|
||||
common.error('Destination file exists', true);
|
||||
@ -46,8 +42,14 @@ function _ln(options, source, dest) {
|
||||
}
|
||||
|
||||
if (options.symlink) {
|
||||
if ((isAbsolute && !fs.existsSync(sourcePath)) || !fs.existsSync(path.resolve(process.cwd(), path.dirname(dest), source))) {
|
||||
common.error('Source file does not exist', true);
|
||||
}
|
||||
fs.symlinkSync(source, dest, os.platform() === "win32" ? "junction" : null);
|
||||
} else {
|
||||
if (!fs.existsSync(source)) {
|
||||
common.error('Source file does not exist', true);
|
||||
}
|
||||
fs.linkSync(source, dest, os.platform() === "win32" ? "junction" : null);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user