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(config-lerna-scopes): ignore packages without name #2514

Merged
merged 1 commit into from Mar 23, 2021
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
5 changes: 5 additions & 0 deletions @commitlint/config-lerna-scopes/fixtures/modules/lerna.json
@@ -0,0 +1,5 @@
{
"lerna": "4",
"version": "1.0.0",
"packages": ["packages/*"]
}
7 changes: 7 additions & 0 deletions @commitlint/config-lerna-scopes/fixtures/modules/package.json
@@ -0,0 +1,7 @@
{
"name": "basic",
"version": "1.0.0",
"devDependencies": {
"lerna": "^4.0.0"
}
}
@@ -0,0 +1,4 @@
{
"name": "a",
"version": "1.0.0"
}
@@ -0,0 +1,3 @@
{
"type": "module"
}
1 change: 1 addition & 0 deletions @commitlint/config-lerna-scopes/index.js
Expand Up @@ -49,6 +49,7 @@ function getPackages(context) {
.then((packages) => {
return packages
.map((pkg) => pkg.name)
.filter(Boolean)
.map((name) => (name.charAt(0) === '@' ? name.split('/')[1] : name));
});
}
Expand Down
8 changes: 8 additions & 0 deletions @commitlint/config-lerna-scopes/index.test.js
Expand Up @@ -60,6 +60,14 @@ test('returns expected value for basic lerna repository', async () => {
expect(value).toEqual(['a', 'b']);
});

test('returns expected value for lerna repository containing modules', async () => {
const {'scope-enum': fn} = config.rules;
const cwd = await lerna.bootstrap('modules', __dirname);

const [, , value] = await fn({cwd});
expect(value).toEqual(['a']);
});

test('returns expected value for scoped lerna repository', async () => {
const {'scope-enum': fn} = config.rules;
const cwd = await lerna.bootstrap('scoped', __dirname);
Expand Down