MCPcopy
hub / github.com/meteor/meteor / getPkgJsonSubsetForDir

Method getPkgJsonSubsetForDir

tools/isobuild/resolver.ts:374–405  ·  view source on GitHub ↗
(dirPath: string)

Source from the content-addressed store, hash-verified

372 }
373
374 private getPkgJsonSubsetForDir(dirPath: string) {
375 const pkgJsonPath = pathJoin(dirPath, "package.json");
376 const pkg = optimisticReadJsonOrNull(pkgJsonPath);
377 if (! pkg) {
378 return null;
379 }
380
381 // Output a JS module that exports just the "name", "version", "main",
382 // and "browser" properties (if defined) from the package.json file.
383 const pkgSubset: Partial<typeof pkg> = {};
384
385 if (has(pkg, "name")) {
386 pkgSubset.name = pkg.name;
387 }
388
389 if (has(pkg, "version")) {
390 pkgSubset.version = pkg.version;
391 }
392
393 this.mainFields.forEach(name => {
394 const value = pkg[name];
395 if (isString(value) ||
396 isObject(value)) {
397 pkgSubset[name] = value;
398 }
399 });
400
401 return {
402 path: pkgJsonPath,
403 pkg: pkgSubset,
404 };
405 }
406
407 private findPkgJsonSubsetForPath(
408 path: string,

Callers 2

resolveMethod · 0.95

Calls 5

pathJoinFunction · 0.85
hasFunction · 0.85
isStringFunction · 0.85
isObjectFunction · 0.50
forEachMethod · 0.45

Tested by

no test coverage detected