Skip to content

Commit 903df4b

Browse files
committed
feat(config-lerna-scopes): support non-standard lerna repos
1 parent 089a7ad commit 903df4b

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed
+6-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
const path = require('path');
2-
const globby = require('globby');
3-
const jsonfile = require('load-json-file');
1+
const Repository = require('lerna/lib/Repository');
42

53
module.exports = {
64
utils: {getPackages},
75
rules: {
8-
'scope-enum': () => getPackages()
9-
.then(names => [2, 'always', names])
6+
'scope-enum': () => [2, 'always', getPackages()]
107
}
118
};
129

1310
function getPackages() {
14-
const root = path.resolve(process.cwd(), './packages');
15-
const glob = path.resolve(root, '*/package.json');
16-
17-
return globby(glob)
18-
.then(paths => Promise.all(paths.map(jsonfile)))
19-
.then(manifests => manifests.map(manifest => manifest.name));
11+
const repo = new Repository(process.cwd());
12+
return repo.packages
13+
.map(pkg => pkg.name)
14+
.map(name => name.charAt(0) === '@' ? name.split('/')[1] : name);
2015
}

@commitlint/config-lerna-scopes/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"homepage": "https://github.com/marionebl/commitlint#readme",
2727
"dependencies": {
2828
"globby": "6.1.0",
29+
"lerna": "^2.0.0",
2930
"load-json-file": "2.0.0"
3031
},
3132
"devDependencies": {

0 commit comments

Comments
 (0)