MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / parse_package_json

Function parse_package_json

src/pipeline/pass_pkgmap.c:288–322  ·  view source on GitHub ↗

JS/TS: package.json — name + entry point resolution */

Source from the content-addressed store, hash-verified

286
287/* JS/TS: package.json — name + entry point resolution */
288static void parse_package_json(const char *source, int source_len, const char *rel_path,
289 cbm_pkg_entries_t *entries) {
290 yyjson_doc *doc = yyjson_read(source, (size_t)source_len, 0);
291 if (!doc) {
292 return;
293 }
294 yyjson_val *root = yyjson_doc_get_root(doc);
295 if (!yyjson_is_obj(root)) {
296 yyjson_doc_free(doc);
297 return;
298 }
299
300 yyjson_val *name_val = yyjson_obj_get(root, "name");
301 if (!yyjson_is_str(name_val)) {
302 yyjson_doc_free(doc);
303 return;
304 }
305 const char *name = yyjson_get_str(name_val);
306 if (!name || name[0] == '\0') {
307 yyjson_doc_free(doc);
308 return;
309 }
310
311 const char *entry = resolve_pkg_entry(root);
312 if (entry) {
313 char *dir = path_dirname(rel_path);
314 char *resolved = join_and_strip(dir, entry);
315 if (resolved) {
316 pkg_entries_push(entries, strdup(name), resolved);
317 }
318 free(dir);
319 }
320
321 yyjson_doc_free(doc);
322}
323
324/* Go: go.mod — module directive */
325static void parse_go_mod(const char *source, int source_len, const char *rel_path,

Callers 1

cbm_pkgmap_try_parseFunction · 0.85

Calls 4

resolve_pkg_entryFunction · 0.85
path_dirnameFunction · 0.85
join_and_stripFunction · 0.85
pkg_entries_pushFunction · 0.85

Tested by

no test coverage detected