Skip to content
Myr

Add import metadata key "optional"

Before adoption: this commit came in with the history the project adopted, so no landing records it.

A library marked is imported if found, but silently skipped if missing. This is the desired semantic for the auto-include at ~/.jq

authored by Muh Muhten · committed by Nico Williams · parent c814c4e · Browse files · 1 file+8 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−1 removed

  • other:+8 added−1 removed

1 file+8 added−1 removed

modified:src/linker.c+8 added-1 removed
244 unmodified lines
245 int raw = 0;246 jv v = jv_object_get(jv_copy(dep), jv_string("raw"));247 if (jv_get_kind(v) == JV_KIND_TRUE)248 raw = 1;249 int optional = 0;250 if (jv_get_kind(jv_object_get(jv_copy(dep), jv_string("optional"))) == JV_KIND_TRUE)251 optional = 1;252 jv_free(v);253 jv relpath = validate_relpath(jv_object_get(jv_copy(dep), jv_string("relpath")));254 jv as = jv_object_get(jv_copy(dep), jv_string("as"));255 assert(!jv_is_valid(as) || jv_get_kind(as) == JV_KIND_STRING);
5 unmodified lines
261 // find_lib does a lot of work that could be cached...262 jv resolved = find_lib(jq, relpath, search, is_data ? ".json" : ".jq", jv_copy(jq_origin), jv_copy(lib_origin));263 // XXX ...move the rest of this into a callback.264 if (!jv_is_valid(resolved)) {265 jv_free(as);266 if (optional) {267 jv_free(resolved);268 continue;269 }270 jv emsg = jv_invalid_get_msg(resolved);271 jq_report_error(jq, jv_string_fmt("jq: error: %s\n",jv_string_value(emsg)));272 jv_free(emsg);265 jv_free(as);273 jv_free(deps);274 jv_free(jq_origin);275 jv_free(lib_origin);276 return 1;
131 unmodified lines