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

Ignoring node_modules folders inside nested workspaces as Lerna scopes #3025

Merged
merged 2 commits into from Feb 14, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -12,3 +12,6 @@ package.json.lerna_backup
/*.iml
tsconfig.tsbuildinfo
coverage

# For testing nested workspaces does not have the package's dependencies name in the scope
!**/config-lerna-scopes/fixtures/nested-workspaces/**/node_modules

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

@@ -0,0 +1,4 @@
{
"name": "@packages/nested-a",
"version": "1.0.0"
}

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

@@ -0,0 +1,4 @@
{
"name": "@packages/nested-b",
"version": "1.0.0"
}
@@ -0,0 +1,11 @@
{
"name": "nested-workspaces",
"version": "1.0.0",
"workspaces": [
"@packages/**"
],
"devDependencies": {
"lerna": "^4.0.0",
"@lerna/project": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion @commitlint/config-lerna-scopes/index.js
Expand Up @@ -25,7 +25,7 @@ function getPackages(context) {
workspaces.map((ws) => {
return Path.posix.join(ws, 'package.json');
}),
{cwd}
{cwd, ignore: ['**/node_modules/**']}
).then((pJsons = []) => {
return pJsons.map((pJson) => require(Path.join(cwd, pJson)));
});
Expand Down
11 changes: 11 additions & 0 deletions @commitlint/config-lerna-scopes/index.test.js
Expand Up @@ -82,3 +82,14 @@ test('returns expected value for yarn workspaces', async () => {
const [, , value] = await fn({cwd});
expect(value.sort()).toEqual(['a', 'b']);
});

test('returns expected value for yarn workspaces has nested packages', async () => {
const {'scope-enum': fn} = config.rules;
const cwd = await npm.bootstrap('fixtures/nested-workspaces', __dirname);

const [, , value] = await fn({cwd});
expect(value).toEqual(expect.arrayContaining(['nested-a', 'nested-b']));
expect(value).toEqual(
expect.not.arrayContaining(['dependency-a', 'dependency-b'])
);
});