MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / findModulePath

Function findModulePath

src/modules/commitlint/pwd-commitlint.ts:4–21  ·  view source on GitHub ↗
(moduleName: string)

Source from the content-addressed store, hash-verified

2import path from 'path';
3
4const findModulePath = (moduleName: string) => {
5 const searchPaths = [
6 path.join('node_modules', moduleName),
7 path.join('node_modules', '.pnpm'),
8 path.resolve(__dirname, '../..')
9 ];
10
11 for (const basePath of searchPaths) {
12 try {
13 const resolvedPath = require.resolve(moduleName, { paths: [basePath] });
14 return resolvedPath;
15 } catch {
16 // Continue to the next search path if the module is not found
17 }
18 }
19
20 throw new Error(`Cannot find module ${moduleName}`);
21};
22
23const getCommitLintModuleType = async (): Promise<'cjs' | 'esm'> => {
24 const packageFile = '@commitlint/load/package.json';

Callers 2

getCommitLintModuleTypeFunction · 0.70
getCommitLintPWDConfigFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…