From 183620653a05f04c4b305b4c49fd209d844ef827 Mon Sep 17 00:00:00 2001 From: yorkie Date: Thu, 19 Nov 2015 22:24:19 +0800 Subject: [PATCH 1/2] fs: fix the error report on fs.link(Sync) --- src/node_file.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index b84e0e44c442b0..2bd32d7daa2bd0 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -615,13 +615,13 @@ static void Link(const FunctionCallbackInfo& 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]); From 082abaea0d857a6afc7e763d320a8e72a84910be Mon Sep 17 00:00:00 2001 From: yorkie Date: Fri, 20 Nov 2015 01:20:09 +0800 Subject: [PATCH 2/2] add test --- test/parallel/test-fs-link.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/parallel/test-fs-link.js b/test/parallel/test-fs-link.js index 4e95d20f7b6959..acbedc1452231d 100644 --- a/test/parallel/test-fs-link.js +++ b/test/parallel/test-fs-link.js @@ -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/ +);