Skip to content

Commit a91c339

Browse files
committed
fix(scripts/commit): use require.resolve to avoid node_modules path
Use `require.resolve` to resolve 'commitizen' path for use in `bootstrap`ing prompt adapter to make resolution more resilient and remove the dependency on `node_modules` directory.
1 parent db3f2bd commit a91c339

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/scripts/commit.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
const fs = require('fs')
2-
const path = require('path')
31
const {bootstrap} = require('commitizen/dist/cli/git-cz')
4-
const {fromRoot} = require('../utils')
52

6-
const here = p => path.join(__dirname, p)
7-
8-
const cliPath = [
9-
here('../../node_modules/commitizen'),
10-
fromRoot('./node_modules/commitizen'),
11-
].find(fs.existsSync)
3+
const commitizenPaths = require.resolve('commitizen/package.json').split('/')
4+
const cliPath = commitizenPaths.slice(0, -1).join('/')
125

136
// eslint-disable-next-line no-warning-comments
147
// FIXME: for some reason invoking this script with `yarn commit` now passes

0 commit comments

Comments
 (0)