Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8b97249

Browse filesBrowse files
yorkiejasnell
authored andcommitted
fs: fix the error report on fs.link(Sync)
As the Node.js documentation specified: > fs.link(srcpath, dstpath, callback) But when we run: ```js > fs.link() ``` We will get the below: ```js TypeError: dest path must be a string at TypeError (native) at Object.fs.link (fs.js:915:11) at repl:1:4 ``` Just correct the message of relevant 2 errors in this PR :-) PR-URL: #3917 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 9472a0c commit 8b97249
Copy full SHA for 8b97249

File tree

Expand file treeCollapse file tree

2 files changed

+20
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+20
-4
lines changed
Open diff view settings
Collapse file

‎src/node_file.cc‎

Copy file name to clipboardExpand all lines: src/node_file.cc
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,13 +615,13 @@ static void Link(const FunctionCallbackInfo<Value>& args) {
615615

616616
int len = args.Length();
617617
if (len < 1)
618-
return TYPE_ERROR("dest path required");
619-
if (len < 2)
620618
return TYPE_ERROR("src path required");
619+
if (len < 2)
620+
return TYPE_ERROR("dest path required");
621621
if (!args[0]->IsString())
622-
return TYPE_ERROR("dest path must be a string");
623-
if (!args[1]->IsString())
624622
return TYPE_ERROR("src path must be a string");
623+
if (!args[1]->IsString())
624+
return TYPE_ERROR("dest path must be a string");
625625

626626
node::Utf8Value orig_path(env->isolate(), args[0]);
627627
node::Utf8Value new_path(env->isolate(), args[1]);
Collapse file

‎test/parallel/test-fs-link.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-link.js
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,19 @@ const callback = function(err) {
1818
};
1919

2020
fs.link(srcPath, dstPath, common.mustCall(callback));
21+
22+
// test error outputs
23+
24+
assert.throws(
25+
function() {
26+
fs.link();
27+
},
28+
/src path/
29+
);
30+
31+
assert.throws(
32+
function() {
33+
fs.link('abc');
34+
},
35+
/dest path/
36+
);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.