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

Function getPackageVersion

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

Source from the content-addressed store, hash-verified

399
400let packageVersionCache = new Map<string, string>();
401function getPackageVersion(pkg: string) {
402 let version = packageVersionCache.get(pkg);
403 if (version) {
404 return version;
405 }
406
407 let p = findPackageJSON(pkg, __filename);
408 if (p) {
409 let json = JSON.parse(fs.readFileSync(p, 'utf8'));
410 packageVersionCache.set(pkg, json.version);
411 return json.version;
412 } else {
413 throw new Error('Could not find package.json for ' + pkg);
414 }
415}
416
417function resolveUrl(specifier: string, file: string) {
418 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