Skip to content

Commit 7c94000

Browse files
committed
fixup! src: move package resolver to c++
1 parent 5f9c573 commit 7c94000

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/node_modules.cc

+20
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,26 @@ const BindingData::PackageConfig* BindingData::GetPackageJSON(
105105

106106
PackageConfig package_config{};
107107
package_config.file_path = path;
108+
109+
#ifdef _AIX
110+
// On AIX, the file read can still succeed even if it's a directory.
111+
// For backporting https://github.com/nodejs/node/pull/50322 to v20.x,
112+
// add the special case back and return early to notify the JS land
113+
// and let it treat it as if the package.json does not exist.
114+
// See https://github.com/libuv/libuv/pull/2025 and
115+
// https://github.com/nodejs/node/pull/48477#issuecomment-1604586650
116+
uv_fs_t req;
117+
int rc = uv_fs_stat(nullptr, &req, path.data(), nullptr);
118+
if (rc == 0) {
119+
const uv_stat_t* const s = static_cast<const uv_stat_t*>(req.ptr);
120+
bool is_dir = ((s->st_mode & S_IFMT) == S_IFDIR);
121+
uv_fs_req_cleanup(&req);
122+
if (is_dir) {
123+
return nullptr;
124+
}
125+
}
126+
#endif
127+
108128
// No need to exclude BOM since simdjson will skip it.
109129
if (ReadFileSync(&package_config.raw_json, path.data()) < 0) {
110130
return nullptr;

0 commit comments

Comments
 (0)