@@ -1828,28 +1828,27 @@ static void RealPath(const FunctionCallbackInfo<Value>& args) {
18281828 Isolate* isolate = env->isolate ();
18291829
18301830 const int argc = args.Length ();
1831- CHECK_GE (argc, 3 );
1831+ CHECK_GE (argc, 2 );
18321832
18331833 BufferValue path (isolate, args[0 ]);
18341834 CHECK_NOT_NULL (*path);
18351835
18361836 const enum encoding encoding = ParseEncoding (isolate, args[1 ], UTF8);
18371837
1838- FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
1839- if ( req_wrap_async != nullptr ) { // realpath(path, encoding, req)
1838+ if (argc > 2 ) { // realpath(path, encoding, req)
1839+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
18401840 FS_ASYNC_TRACE_BEGIN1 (
18411841 UV_FS_REALPATH, req_wrap_async, " path" , TRACE_STR_COPY (*path))
18421842 AsyncCall (env, req_wrap_async, args, " realpath" , encoding, AfterStringPtr,
18431843 uv_fs_realpath, *path);
18441844 } else { // realpath(path, encoding, undefined, ctx)
1845- CHECK_EQ (argc, 4 );
1846- FSReqWrapSync req_wrap_sync;
1845+ FSReqWrapSync req_wrap_sync (" realpath" , *path);
18471846 FS_SYNC_TRACE_BEGIN (realpath);
1848- int err = SyncCall (env, args[ 3 ], &req_wrap_sync, " realpath " ,
1849- uv_fs_realpath, *path);
1847+ int err =
1848+ SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_realpath, *path);
18501849 FS_SYNC_TRACE_END (realpath);
18511850 if (err < 0 ) {
1852- return ; // syscall failed, no need to continue, error info is in ctx
1851+ return ;
18531852 }
18541853
18551854 const char * link_path = static_cast <const char *>(req_wrap_sync.req .ptr );
@@ -1860,8 +1859,7 @@ static void RealPath(const FunctionCallbackInfo<Value>& args) {
18601859 encoding,
18611860 &error);
18621861 if (rc.IsEmpty ()) {
1863- Local<Object> ctx = args[3 ].As <Object>();
1864- ctx->Set (env->context (), env->error_string (), error).Check ();
1862+ env->isolate ()->ThrowException (error);
18651863 return ;
18661864 }
18671865
0 commit comments