Skip to content

Commit

Permalink
Use findPnpApi
Browse files Browse the repository at this point in the history
  • Loading branch information
louisscruz committed Jun 14, 2022
1 parent 003f602 commit 104ef09
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/ResolverFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,8 @@ function processPnpApiOption(option) {
option === undefined &&
/** @type {NodeJS.ProcessVersions & {pnp: string}} */ versions.pnp
) {
try {
// @ts-ignore
return require("pnpapi"); // eslint-disable-line node/no-missing-require
} catch (e) {
// In some rare cases, versions.pnp might be set, but `pnpapi` might not resolve
return null;
}
// @ts-ignore
return require("module").findPnpApi(process.cwd());
}

return option || null;
Expand Down
1 change: 1 addition & 0 deletions test/pnp.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ describe("pnp", () => {
it("should not resolve a not fully specified request when fullySpecified is set", done => {
pnpApi.mocks.set("pkg", path.resolve(fixture, "pkg"));
resolver.resolve({}, __dirname, "pkg/dir/index", {}, (err, result) => {
console.log("...", err);
err.should.be.instanceof(Error);
done();
});
Expand Down

0 comments on commit 104ef09

Please sign in to comment.