Skip to content
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

fs: fix the error report on fs.link(Sync) #3917

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,13 @@ static void Link(const FunctionCallbackInfo<Value>& args) {

int len = args.Length();
if (len < 1)
return TYPE_ERROR("dest path required");
if (len < 2)
return TYPE_ERROR("src path required");
if (len < 2)
return TYPE_ERROR("dest path required");
if (!args[0]->IsString())
return TYPE_ERROR("dest path must be a string");
if (!args[1]->IsString())
return TYPE_ERROR("src path must be a string");
if (!args[1]->IsString())
return TYPE_ERROR("dest path must be a string");

node::Utf8Value orig_path(env->isolate(), args[0]);
node::Utf8Value new_path(env->isolate(), args[1]);
Expand Down
16 changes: 16 additions & 0 deletions test/parallel/test-fs-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,19 @@ const callback = function(err) {
};

fs.link(srcPath, dstPath, common.mustCall(callback));

// test error outputs

assert.throws(
function() {
fs.link();
},
/src path/
);

assert.throws(
function() {
fs.link('abc');
},
/dest path/
);