summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-01-24 07:03:11 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2018-02-01 15:52:18 +0800
commit167e22937c612e18678e45e73a89dcc27e72fdc5 (patch)
tree44544a4b2f4371231c5721cd4977244e9c6fb8de /lib
parent32bf0f6c5b3648a487c3fc56d0830de2ceeb60a5 (diff)
downloadandroid-node-v8-167e22937c612e18678e45e73a89dcc27e72fdc5.tar.gz
android-node-v8-167e22937c612e18678e45e73a89dcc27e72fdc5.tar.bz2
android-node-v8-167e22937c612e18678e45e73a89dcc27e72fdc5.zip
fs: throw errors from fs.linkSync in JS
PR-URL: https://github.com/nodejs/node/pull/18348 Refs: https://github.com/nodejs/node/issues/18106 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/fs.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/fs.js b/lib/fs.js
index c75a8501b6..4a69ef9bc4 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -1280,8 +1280,15 @@ fs.linkSync = function(existingPath, newPath) {
nullCheck(newPath);
validatePath(existingPath, 'existingPath');
validatePath(newPath, 'newPath');
- return binding.link(pathModule.toNamespacedPath(existingPath),
- pathModule.toNamespacedPath(newPath));
+
+ const ctx = { path: existingPath, dest: newPath };
+ const result = binding.link(pathModule.toNamespacedPath(existingPath),
+ pathModule.toNamespacedPath(newPath),
+ undefined, ctx);
+ if (ctx.errno !== undefined) {
+ throw new errors.uvException(ctx);
+ }
+ return result;
};
fs.unlink = function(path, callback) {