MCPcopy
hub / github.com/ChromeDevTools/chrome-devtools-mcp / getPackageName

Function getPackageName

rollup.config.mjs:62–79  ·  view source on GitHub ↗
(modulePath)

Source from the content-addressed store, hash-verified

60 path.join(process.cwd(), 'node_modules') + path.sep;
61
62function getPackageName(modulePath) {
63 // Handle rollup's virtual module paths (paths starting with 0x00)
64 const absolutePathStart = modulePath.indexOf(projectNodeModulesPath);
65 if (absolutePathStart < 0) {
66 return null;
67 }
68
69 const relativePath = modulePath.slice(
70 projectNodeModulesPath.length + absolutePathStart,
71 );
72 const segments = relativePath.split(path.sep);
73
74 // handle scoped packages
75 if (segments[0].startsWith('@') && segments[1]) {
76 return `${segments[0]}/${segments[1]}`;
77 }
78 return segments[0];
79}
80
81/**
82 * @returns {import('rollup').Plugin}

Callers 1

generateBundleFunction · 0.85

Calls 2

sliceMethod · 0.80
splitMethod · 0.80

Tested by

no test coverage detected