Skip to content

Commit

Permalink
fix: lerna package.json resolution (#3600)
Browse files Browse the repository at this point in the history
  • Loading branch information
backflip authored May 2, 2023
1 parent 7e2a84e commit 6c5cd53
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 11 additions & 2 deletions @commitlint/config-lerna-scopes/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const glob = require('glob');
const Path = require('path');
const importFrom = require('import-from');
const resolvePkg = require('resolve-pkg');
const semver = require('semver');

module.exports = {
Expand Down Expand Up @@ -54,5 +53,15 @@ function getPackages(context) {
}

function getLernaVersion(cwd) {
return require(Path.join(resolvePkg('lerna', {cwd}), 'package.json')).version;
const moduleEntrypoint = require.resolve('lerna', {
paths: [cwd],
});
const moduleDir = Path.join(
moduleEntrypoint.slice(0, moduleEntrypoint.lastIndexOf('node_modules')),
'node_modules',
'lerna'
);
const modulePackageJson = Path.join(moduleDir, 'package.json');

return require(modulePackageJson).version;
}
1 change: 0 additions & 1 deletion @commitlint/config-lerna-scopes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"dependencies": {
"glob": "^8.0.3",
"import-from": "4.0.0",
"resolve-pkg": "2.0.0",
"semver": "7.3.8"
},
"devDependencies": {
Expand Down

0 comments on commit 6c5cd53

Please sign in to comment.