Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pnp): Avoid infinite loop in findApiPathFor #1298

Merged
merged 5 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/packages/yarnpkg-pnp/sources/hook.js

/packages/yarnpkg-libzip/sources/libzipAsync.js
/packages/yarnpkg-libzip/sources/libzipSync.js

Expand Down
79 changes: 38 additions & 41 deletions .pnp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions .yarn/versions/45869421.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
releases:
"@yarnpkg/cli": prerelease
"@yarnpkg/fslib": prerelease
"@yarnpkg/pnp": prerelease

declined:
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-file"
- "@yarnpkg/plugin-git"
- "@yarnpkg/plugin-github"
- "@yarnpkg/plugin-http"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-link"
- "@yarnpkg/plugin-node-modules"
- "@yarnpkg/plugin-npm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- vscode-zipfs
- "@yarnpkg/builder"
- "@yarnpkg/core"
- "@yarnpkg/doctor"
- "@yarnpkg/json-proxy"
- "@yarnpkg/pnpify"
- "@yarnpkg/shell"
40 changes: 40 additions & 0 deletions packages/acceptance-tests/pkg-tests-specs/sources/pnp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,46 @@ describe(`Plug'n'Play`, () => {
),
);

testIf(
() => satisfies(process.versions.node, `>=8.9.0`),
`it should terminate when the 'paths' option from require.resolve includes empty string and there is no .pnp.js in the working dir`,
makeTemporaryEnv(
{
private: true,
workspaces: [`workspace-*`],
},
async ({path, run, source}) => {
await writeJson(`${path}/workspace-a/package.json`, {
name: `workspace-a`,
version: `1.0.0`,
dependencies: {[`no-deps`]: `1.0.0`},
});

await writeJson(`${path}/workspace-b/package.json`, {
name: `workspace-b`,
version: `1.0.0`,
dependencies: {[`no-deps`]: `2.0.0`, [`one-fixed-dep`]: `1.0.0`},
});

await run(`install`);

await expect(
source(
`require(require.resolve('no-deps', {paths: ${JSON.stringify([
`${npath.fromPortablePath(path)}/workspace-a`,
`${npath.fromPortablePath(path)}/workspace-b`,
``,
])}}))`,
{cwd: `${path}/workspace-a`}
),
).resolves.toMatchObject({
name: `no-deps`,
version: `1.0.0`,
});
},
),
);

// Skipped because not supported (we can't require files from within other dependency trees, since we couldn't
// reconcile them together: dependency tree A could think that package X has deps Y@1 while dependency tree B
// could think that X has deps Y@2 instead. Since they would share the same location on the disk, PnP wouldn't
Expand Down
Loading