Skip to content

Allow ln destination to be an existing directory, fixes #832 #833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implement first review feedback
  • Loading branch information
loilo committed Apr 5, 2018
commit 50e6ca8da49a489ef13f05aab8dfe16d7c7803fc
2 changes: 1 addition & 1 deletion src/ln.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function _ln(options, source, dest) {
dest = path.resolve(process.cwd(), String(dest));

if (fs.existsSync(dest) && common.statFollowLinks(dest).isDirectory(dest)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think isDirectory() accepts arguments: https://nodejs.org/api/fs.html#fs_stats_isdirectory

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right. That was definitely not on purpose. 😅

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

dest = path.resolve(dest, path.basename(sourcePath));
dest = path.join(dest, path.basename(sourcePath));
}

if (fs.existsSync(dest)) {
Expand Down
4 changes: 2 additions & 2 deletions test/ln.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ test('destination already exists inside directory', t => {
const result = shell.ln('-s', 'file1', './');
t.truthy(shell.error());
t.is(result.code, 1);
shell.cd('..');
});

test('non-existent source', t => {
Expand Down Expand Up @@ -149,12 +148,13 @@ test('Inside existing directory', t => {
shell.cd(t.context.tmp);
const result = shell.ln('-s', 'external/node_script.js', './');
t.is(result.code, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: also assert .stderr and shell.error() are empty

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to add those. It's not been done anywhere in the ln() tests, and I mostly got inspiration from the other tests around there. 🙈

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check.

t.falsy(result.stderr);
t.falsy(shell.error());
t.truthy(fs.existsSync('node_script.js'));
t.is(
fs.readFileSync('external/node_script.js').toString(),
fs.readFileSync('node_script.js').toString()
);
shell.rm('node_script.js');
shell.cd('..');
});

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy