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

Function parse_package_json

src/pipeline/pass_pkgmap.c:284–318  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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