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(pnpm): absolute cwd path matched workspace exclude rules (#121) #122

Merged
merged 4 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 6 additions & 0 deletions .changeset/fair-days-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@manypkg/cli": patch
"@manypkg/get-packages": patch
---

fix absolute cwd path matched pnpm worksapce exclude rules
fz6m marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 6 additions & 0 deletions __fixtures__/pnpm-exclude-workspace-case/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"name": "pnpm-exclude-workspace-case",
"description": "pnpm exclude rule workspace work",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "pnpm-exclude-workspace-case-pkg-a",
"version": "1.0.0",
"dependencies": {
"pnpm-exclude-workspace-case-pkg-b": "1.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

{
"name": "pnpm-exclude-workspace-case-pkg-b",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

{
"name": "pnpm-exclude-workspace-case-excluded-pkg",
"version": "1.0.0"
}
5 changes: 5 additions & 0 deletions __fixtures__/pnpm-exclude-workspace-case/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
packages:
- 'packages/**'
# exclude packages that are inside myself name directories
- '!**/pnpm-exclude-workspace-case/**'

13 changes: 13 additions & 0 deletions packages/get-packages/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ let runTests = (getPackages: GetPackages) => {
expect(allPackages.tool).toEqual("pnpm");
});

it("should resolve workspace for pnpm with exclude rules", async () => {
const allPackages = await getPackages(f.copy("pnpm-exclude-workspace-case"));

expect(allPackages.packages[0].packageJson.name).toEqual(
"pnpm-exclude-workspace-case-pkg-a"
);
expect(allPackages.packages[1].packageJson.name).toEqual(
"pnpm-exclude-workspace-case-pkg-b"
);
expect(allPackages.packages.length).toEqual(2);
expect(allPackages.tool).toEqual("pnpm");
})

it("should resolve workspaces for lerna", async () => {
const allPackages = await getPackages(f.copy("lerna-workspace-base"));

Expand Down
8 changes: 4 additions & 4 deletions packages/get-packages/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ export async function getPackages(dir: string): Promise<Packages> {
};
}

const directories = await globby(tool.packageGlobs, {
const relativeDirectories = await globby(tool.packageGlobs, {
cwd,
onlyDirectories: true,
absolute: true,
expandDirectories: false,
ignore: ["**/node_modules"]
});
const directories = relativeDirectories.map(p => path.resolve(cwd, p))

let pkgJsonsMissingNameField: Array<string> = [];

Expand Down Expand Up @@ -234,13 +234,13 @@ export function getPackagesSync(dir: string): Packages {
packages: [root]
};
}
const directories = globbySync(tool.packageGlobs, {
const relativeDirectories = globbySync(tool.packageGlobs, {
cwd,
onlyDirectories: true,
absolute: true,
expandDirectories: false,
ignore: ["**/node_modules"]
});
const directories = relativeDirectories.map(p => path.resolve(cwd, p))

let pkgJsonsMissingNameField: Array<string> = [];

Expand Down