@@ -1562,25 +1562,23 @@ static void RMDir(const FunctionCallbackInfo<Value>& args) {
15621562 Environment* env = Environment::GetCurrent (args);
15631563
15641564 const int argc = args.Length ();
1565- CHECK_GE (argc, 2 );
1565+ CHECK_GE (argc, 1 );
15661566
15671567 BufferValue path (env->isolate (), args[0 ]);
15681568 CHECK_NOT_NULL (*path);
15691569 THROW_IF_INSUFFICIENT_PERMISSIONS (
15701570 env, permission::PermissionScope::kFileSystemWrite , path.ToStringView ());
15711571
1572- FSReqBase* req_wrap_async = GetReqWrap (args, 1 ); // rmdir(path, req)
1573- if ( req_wrap_async != nullptr ) {
1572+ if (argc > 1 ) {
1573+ FSReqBase* req_wrap_async = GetReqWrap (args, 1 ); // rmdir(path, req)
15741574 FS_ASYNC_TRACE_BEGIN1 (
15751575 UV_FS_RMDIR, req_wrap_async, " path" , TRACE_STR_COPY (*path))
15761576 AsyncCall (env, req_wrap_async, args, " rmdir" , UTF8, AfterNoArgs,
15771577 uv_fs_rmdir, *path);
1578- } else { // rmdir(path, undefined, ctx)
1579- CHECK_EQ (argc, 3 );
1580- FSReqWrapSync req_wrap_sync;
1578+ } else { // rmdir(path)
1579+ FSReqWrapSync req_wrap_sync (" rmdir" , *path);
15811580 FS_SYNC_TRACE_BEGIN (rmdir);
1582- SyncCall (env, args[2 ], &req_wrap_sync, " rmdir" ,
1583- uv_fs_rmdir, *path);
1581+ SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_rmdir, *path);
15841582 FS_SYNC_TRACE_END (rmdir);
15851583 }
15861584}
0 commit comments