Skip to content

Commit

Permalink
feat(config-lerna-scopes): support non-standard lerna repos
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl committed Jul 10, 2017
1 parent 089a7ad commit 903df4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
17 changes: 6 additions & 11 deletions @commitlint/config-lerna-scopes/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
const path = require('path');
const globby = require('globby');
const jsonfile = require('load-json-file');
const Repository = require('lerna/lib/Repository');

module.exports = {
utils: {getPackages},
rules: {
'scope-enum': () => getPackages()
.then(names => [2, 'always', names])
'scope-enum': () => [2, 'always', getPackages()]
}
};

function getPackages() {
const root = path.resolve(process.cwd(), './packages');
const glob = path.resolve(root, '*/package.json');

return globby(glob)
.then(paths => Promise.all(paths.map(jsonfile)))
.then(manifests => manifests.map(manifest => manifest.name));
const repo = new Repository(process.cwd());
return repo.packages
.map(pkg => pkg.name)
.map(name => name.charAt(0) === '@' ? name.split('/')[1] : name);
}
1 change: 1 addition & 0 deletions @commitlint/config-lerna-scopes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"homepage": "https://github.com/marionebl/commitlint#readme",
"dependencies": {
"globby": "6.1.0",
"lerna": "^2.0.0",
"load-json-file": "2.0.0"
},
"devDependencies": {
Expand Down

0 comments on commit 903df4b

Please sign in to comment.