Expose the names of a module's defined function via modulemeta
This reuses the existing `block_list_funcs` capability and adds an extra field on the `modulemeta` output, called `defs`, containing that list of functions.
This commit is contained in:
1 parent
fdab39bc7b
commit
65ed95c93a
2 files changed
+8
-3
No files matched your search
@@ -390,6 +390,7 @@ jv load_module_meta(jq_state *jq, jv mod_relpath) {
|
||||
if (jv_get_kind(meta) == JV_KIND_NULL)
|
||||
meta = jv_object();
|
||||
meta = jv_object_set(meta, jv_string("deps"), block_take_imports(&program));
|
||||
meta = jv_object_set(meta, jv_string("defs"), block_list_funcs(program, 0));
|
||||
}
|
||||
locfile_free(src);
|
||||
block_free(program);
|
||||
|
||||
+7
-3
@@ -1624,11 +1624,15 @@ jq: error: Import path must be constant at <top-level>, line 1:
|
||||
|
||||
modulemeta
|
||||
"c"
|
||||
{"whatever":null,"deps":[{"as":"foo","is_data":false,"relpath":"a"},{"search":"./","as":"d","is_data":false,"relpath":"d"},{"search":"./","as":"d2","is_data":false,"relpath":"d"},{"search":"./../lib/jq","as":"e","is_data":false,"relpath":"e"},{"search":"./../lib/jq","as":"f","is_data":false,"relpath":"f"},{"as":"d","is_data":true,"relpath":"data"}]}
|
||||
{"whatever":null,"deps":[{"as":"foo","is_data":false,"relpath":"a"},{"search":"./","as":"d","is_data":false,"relpath":"d"},{"search":"./","as":"d2","is_data":false,"relpath":"d"},{"search":"./../lib/jq","as":"e","is_data":false,"relpath":"e"},{"search":"./../lib/jq","as":"f","is_data":false,"relpath":"f"},{"as":"d","is_data":true,"relpath":"data"}],"defs":["a/0","c/0"]}
|
||||
|
||||
modulemeta | .deps |= length
|
||||
modulemeta | .deps | length
|
||||
"c"
|
||||
{"whatever":null,"deps":6}
|
||||
6
|
||||
|
||||
modulemeta | .defs | length
|
||||
"c"
|
||||
2
|
||||
|
||||
%%FAIL IGNORE MSG
|
||||
import "syntaxerror" as e; .
|
||||
|
||||
Reference in new issue
Block a user