Skip to content

Commit

Permalink
Fixes findPackageLocator on parent directories (#2061)
Browse files Browse the repository at this point in the history
* Fixes a bug in findPackageLocator

* Versions
  • Loading branch information
arcanis committed Oct 28, 2020
1 parent ae5d9e4 commit 7abc794
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .pnp.js

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

24 changes: 24 additions & 0 deletions .yarn/versions/83802125.yml
@@ -0,0 +1,24 @@
releases:
"@yarnpkg/cli": patch
"@yarnpkg/plugin-pnp": patch
"@yarnpkg/pnp": patch

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-node-modules"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/core"
- "@yarnpkg/doctor"
- "@yarnpkg/pnpify"
Expand Up @@ -19,6 +19,15 @@ describe(`Plug'n'Play API`, () => {
);

describe(`std - v1`, () => {
test(
`it shouldn't report the project parent directory as being part of the project`,
makeTemporaryEnv({}, async ({path, run, source}) => {
await run(`install`);

await expect(source(`require('pnpapi').findPackageLocator('${npath.fromPortablePath(ppath.dirname(path))}/')`)).resolves.toEqual(null);
}),
);

test(
`it should expose resolveToUnqualified`,
makeTemporaryEnv({}, async ({path, run, source}) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/yarnpkg-pnp/sources/hook.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/yarnpkg-pnp/sources/loader/makeApi.ts
Expand Up @@ -38,7 +38,7 @@ export function makeApi(runtimeState: RuntimeState, opts: MakeApiOptions): PnpAp

// Matches if the path starts with a valid path qualifier (./, ../, /)
// eslint-disable-next-line no-unused-vars
const isStrictRegExp = /^\.{0,2}\//;
const isStrictRegExp = /^(\/|\.{1,2}(\/|$))/;

// Matches if the path must point to a directory (ie ends with /)
const isDirRegExp = /\/$/;
Expand Down

0 comments on commit 7abc794

Please sign in to comment.