MCPcopy Create free account
hub / github.com/uiwjs/react-codemirror / resolveVersionRange

Function resolveVersionRange

extensions/langs/gen-langs-map.cjs:325–340  ·  view source on GitHub ↗
(pkgName)

Source from the content-addressed store, hash-verified

323}
324
325function resolveVersionRange(pkgName) {
326 // 先找本包 node_modules,再找 monorepo 根 node_modules
327 const candidates = [
328 path.resolve(__dirname, 'node_modules', pkgName, 'package.json'),
329 path.resolve(__dirname, '../../node_modules', pkgName, 'package.json'),
330 ];
331 for (const p of candidates) {
332 if (fs.existsSync(p)) {
333 const { version } = JSON.parse(fs.readFileSync(p, 'utf8'));
334 const [major, minor] = version.split('.');
335 // 0.x 版本下 ^0.0.0 范围太窄(仅匹配 <0.1.0),需用 ^0.minor.0
336 return major === '0' ? `^0.${minor}.0` : `^${major}.0.0`;
337 }
338 }
339 return null;
340}
341
342// 1) 收集所有被导入的包名
343const allModules = new Set();

Callers 1

gen-langs-map.cjsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…