MCPcopy Create free account
hub / github.com/Snapchat/Valdi / extractModuleName

Function extractModuleName

npm_modules/cli/src/core/analyze/scanner.ts:176–185  ·  view source on GitHub ↗
(filePath: string, config: ScanConfig)

Source from the content-addressed store, hash-verified

174}
175
176export function extractModuleName(filePath: string, config: ScanConfig): string | undefined {
177 for (const root of config.scanRoots) {
178 if (filePath === root || filePath.startsWith(root + path.sep)) {
179 const relative = path.relative(root, filePath);
180 const firstSegment = relative.split(path.sep)[0];
181 return firstSegment;
182 }
183 }
184 return undefined;
185}
186
187export function isSharedLibFile(filePath: string, config: ScanConfig): boolean {
188 return config.sharedLibPaths.some(libPath => filePath === libPath || filePath.startsWith(libPath + path.sep));

Callers 2

parseFileFunction · 0.90
walkDirFunction · 0.85

Calls 2

startsWithMethod · 0.80
splitMethod · 0.80

Tested by

no test coverage detected