@@ -1588,25 +1588,23 @@ static void RMDir(const FunctionCallbackInfo<Value>& args) {
15881588 Environment* env = Environment::GetCurrent (args);
15891589
15901590 const int argc = args.Length ();
1591- CHECK_GE (argc, 2 );
1591+ CHECK_GE (argc, 1 );
15921592
15931593 BufferValue path (env->isolate (), args[0 ]);
15941594 CHECK_NOT_NULL (*path);
15951595 THROW_IF_INSUFFICIENT_PERMISSIONS (
15961596 env, permission::PermissionScope::kFileSystemWrite , path.ToStringView ());
15971597
1598- FSReqBase* req_wrap_async = GetReqWrap (args, 1 ); // rmdir(path, req)
1599- if ( req_wrap_async != nullptr ) {
1598+ if (argc > 1 ) {
1599+ FSReqBase* req_wrap_async = GetReqWrap (args, 1 ); // rmdir(path, req)
16001600 FS_ASYNC_TRACE_BEGIN1 (
16011601 UV_FS_RMDIR, req_wrap_async, " path" , TRACE_STR_COPY (*path))
16021602 AsyncCall (env, req_wrap_async, args, " rmdir" , UTF8, AfterNoArgs,
16031603 uv_fs_rmdir, *path);
1604- } else { // rmdir(path, undefined, ctx)
1605- CHECK_EQ (argc, 3 );
1606- FSReqWrapSync req_wrap_sync;
1604+ } else { // rmdir(path)
1605+ FSReqWrapSync req_wrap_sync (" rmdir" , *path);
16071606 FS_SYNC_TRACE_BEGIN (rmdir);
1608- SyncCall (env, args[2 ], &req_wrap_sync, " rmdir" ,
1609- uv_fs_rmdir, *path);
1607+ SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_rmdir, *path);
16101608 FS_SYNC_TRACE_END (rmdir);
16111609 }
16121610}
0 commit comments