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

Function getPackageVersion

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

Source from the content-addressed store, hash-verified

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