Skip to content

Commit

Permalink
fixup! src: move package resolver to c++
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Jan 15, 2025
1 parent 5f9c573 commit aff90b3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/node_modules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,26 @@ const BindingData::PackageConfig* BindingData::GetPackageJSON(

PackageConfig package_config{};
package_config.file_path = path;

#ifdef _AIX
// On AIX, the file read can still succeed even if it's a directory.
// For backporting https://github.com/nodejs/node/pull/50322 to v20.x,
// add the special case back and return early to notify the JS land
// and let it treat it as if the package.json does not exist.
// See https://github.com/libuv/libuv/pull/2025 and
// https://github.com/nodejs/node/pull/48477#issuecomment-1604586650
uv_fs_t req;
int rc = uv_fs_stat(nullptr, &req, *path, nullptr);
if (rc == 0) {
const uv_stat_t* const s = static_cast<const uv_stat_t*>(req.ptr);
boo is_dir = ((s->st_mode & S_IFMT) == S_IFDIR);
uv_fs_req_cleanup(&req);
if (is_dir) {
return nullptr;
}
}
#endif

// No need to exclude BOM since simdjson will skip it.
if (ReadFileSync(&package_config.raw_json, path.data()) < 0) {
return nullptr;
Expand Down

0 comments on commit aff90b3

Please sign in to comment.