MCPcopy Create free account
hub / github.com/SethGammon/Citadel / readPackageMetadata

Function readPackageMetadata

core/map/index.js:375–400  ·  view source on GitHub ↗
(rootDir)

Source from the content-addressed store, hash-verified

373}
374
375function readPackageMetadata(rootDir) {
376 const packagePath = path.join(rootDir, 'package.json');
377 if (!fs.existsSync(packagePath)) {
378 return { packageScripts: {}, verificationCommands: [] };
379 }
380
381 let parsed;
382 try {
383 parsed = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
384 } catch (_) {
385 return { packageScripts: {}, verificationCommands: [] };
386 }
387
388 const scripts = parsed.scripts || {};
389 const packageScripts = {};
390 const verificationCommands = [];
391
392 for (const [name, command] of Object.entries(scripts)) {
393 packageScripts[name] = command;
394 if (VERIFICATION_SCRIPT_PATTERN.test(name) || VERIFICATION_SCRIPT_PATTERN.test(command)) {
395 verificationCommands.push(`npm run ${name}`);
396 }
397 }
398
399 return { packageScripts, verificationCommands };
400}
401
402function generateMapIndex(rootDir) {
403 const resolvedRoot = path.resolve(rootDir || process.cwd());

Callers 1

generateMapIndexFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected