Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(config-lerna-scopes): ignore packages without names (#2514)
Some packages now include package.json file in sub-directories which dont contain names
  • Loading branch information
peter-mouland committed Mar 23, 2021
1 parent 5113f22 commit df3bf71
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
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

0 comments on commit df3bf71

Please sign in to comment.