-
Notifications
You must be signed in to change notification settings - Fork 744
Symbolic links are broken! #100
Copy link
Copy link
Closed
Description
The new ln function does not work correctly in some cases:
# Setup
mkdir test-shelljs-ln
cd test-shelljs-ln
mkdir -p dir1/dir2/
echo file1_contents > dir1/file1.txt
# Create a link the old-fashioned way
ln -s ../file1.txt dir1/dir2/link1
# Create a link the new way
npm install 'shelljs@git://github.com/arturadib/shelljs.git#284fc1cc34'
node -e "require('shelljs').ln('-s', '../file1.txt', 'dir1/dir2/link2');"
# shelljs prints this error message:
#ln: Source file does not exist
# Inspect the results
ls -la dir1/dir2/
# output contains the following:
#lrwxrwxrwx 1 me me 12 Dec 27 22:47 link1 -> ../file1.txt
#lrwxrwxrwx 1 me me 32 Dec 27 22:49 link2 -> /home/me/file1.txt
# Clean up
cd ..
rm -r test-shelljs-lnSo, there are a couple of problems here:
- The source of a symbolic link doesn't have to exist relative to the current directory.
- The source of a symbolic link shouldn't be resolved relative to the current directory. If you really want to check for the existence of the source file, resolve the source path relative to the destination directory, but POSIX
lndoesn't do this.
The second issue prevents relative links from being created. The link2 created by shelljs above points to a file that does not exist.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels