MCPcopy Create free account
hub / github.com/adobe/react-spectrum / getPackageVersion

Function getPackageVersion

packages/dev/s2-docs/src/CodeBlock.tsx:377–391  ·  view source on GitHub ↗
(pkg: string)

Source from the content-addressed store, hash-verified

375
376let packageVersionCache = new Map<string, string>();
377function getPackageVersion(pkg: string) {
378 let version = packageVersionCache.get(pkg);
379 if (version) {
380 return version;
381 }
382
383 let p = findPackageJSON(pkg, __filename);
384 if (p) {
385 let json = JSON.parse(fs.readFileSync(p, 'utf8'));
386 packageVersionCache.set(pkg, json.version);
387 return json.version;
388 } else {
389 throw new Error('Could not find package.json for ' + pkg);
390 }
391}
392
393function resolveUrl(specifier: string, file: string) {
394 let relative = path.relative(path.resolve('pages'), path.dirname(file)).split(/[/\\]/);

Callers 1

parseFileFunction · 0.85

Calls 2

parseMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected