diff --git a/src/node_config_file.cc b/src/node_config_file.cc index 1a19465c728ebc..e6c049b4d14f10 100644 --- a/src/node_config_file.cc +++ b/src/node_config_file.cc @@ -55,6 +55,10 @@ ParseResult ConfigReader::ProcessOptionValue( if (result) { // If the value is true, we need to set the flag output->push_back(option_name); + } else { + // Ensure negation is made putting the "--no-" prefix + output->push_back("--no-" + + option_name.substr(2, option_name.size() - 2)); } break; diff --git a/src/node_file-inl.h b/src/node_file-inl.h index ac74ab8f27f53b..29d8a12c429cb6 100644 --- a/src/node_file-inl.h +++ b/src/node_file-inl.h @@ -287,21 +287,27 @@ FSReqBase* GetReqWrap(const v8::FunctionCallbackInfo& args, int index, bool use_bigint) { v8::Local value = args[index]; + FSReqBase* result = nullptr; if (value->IsObject()) { - return BaseObject::Unwrap(value.As()); - } - - Realm* realm = Realm::GetCurrent(args); - BindingData* binding_data = realm->GetBindingData(); - - if (value->StrictEquals(realm->isolate_data()->fs_use_promises_symbol())) { - if (use_bigint) { - return FSReqPromise::New(binding_data, use_bigint); - } else { - return FSReqPromise::New(binding_data, use_bigint); + result = BaseObject::Unwrap(value.As()); + } else { + Realm* realm = Realm::GetCurrent(args); + BindingData* binding_data = realm->GetBindingData(); + + if (value->StrictEquals(realm->isolate_data()->fs_use_promises_symbol())) { + if (use_bigint) { + result = + FSReqPromise::New(binding_data, use_bigint); + } else { + result = + FSReqPromise::New(binding_data, use_bigint); + } } } - return nullptr; + if (result != nullptr) { + result->SetReturnValue(args); + } + return result; } // Returns nullptr if the operation fails from the start. @@ -320,10 +326,7 @@ FSReqBase* AsyncDestCall(Environment* env, FSReqBase* req_wrap, uv_req->path = nullptr; after(uv_req); // after may delete req_wrap if there is an error req_wrap = nullptr; - } else { - req_wrap->SetReturnValue(args); } - return req_wrap; } diff --git a/src/node_file.cc b/src/node_file.cc index 9636e42a9d556d..2a2384c88c63d7 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -2473,8 +2473,6 @@ static void WriteString(const FunctionCallbackInfo& args) { uv_req->path = nullptr; AfterInteger(uv_req); // after may delete req_wrap_async if there is // an error - } else { - req_wrap_async->SetReturnValue(args); } } else { // write(fd, string, pos, enc, undefined, ctx) CHECK_EQ(argc, 6); diff --git a/test/fixtures/permission/fs-write.js b/test/fixtures/permission/fs-write.js index 9ac9a30facc196..cd57591c3b0d28 100644 --- a/test/fixtures/permission/fs-write.js +++ b/test/fixtures/permission/fs-write.js @@ -211,6 +211,12 @@ const relativeProtectedFolder = process.env.RELATIVEBLOCKEDFOLDER; code: 'ERR_ACCESS_DENIED', permission: 'FileSystemWrite', })); + assert.rejects(async () => { + await fs.promises.mkdtemp(path.join(blockedFolder, 'any-folder')); + }, { + code: 'ERR_ACCESS_DENIED', + permission: 'FileSystemWrite', + }); } // fs.mkdtempDisposableSync diff --git a/test/fixtures/rc/warnings-false.json b/test/fixtures/rc/warnings-false.json new file mode 100644 index 00000000000000..55ca24aac3a503 --- /dev/null +++ b/test/fixtures/rc/warnings-false.json @@ -0,0 +1,5 @@ +{ + "nodeOptions": { + "warnings": false + } +} diff --git a/test/parallel/test-config-file.js b/test/parallel/test-config-file.js index 75d0922630cd3a..cc235bfadae146 100644 --- a/test/parallel/test-config-file.js +++ b/test/parallel/test-config-file.js @@ -60,6 +60,17 @@ test('should parse boolean flag', async () => { strictEqual(result.code, 0); }); +test('should parse boolean flag defaulted to true', async () => { + const result = await spawnPromisified(process.execPath, [ + '--experimental-config-file', + fixtures.path('rc/warnings-false.json'), + '-p', 'process.emitWarning("A warning")', + ]); + strictEqual(result.stderr, ''); + strictEqual(result.stdout, 'undefined\n'); + strictEqual(result.code, 0); +}); + test('should throw an error when a flag is declared twice', async () => { const result = await spawnPromisified(process.execPath, [ '--no-warnings',