MCPcopy Create free account
hub / github.com/GNOME/gjs / import_file

Method import_file

gjs/module.cpp:149–163  ·  view source on GitHub ↗

Loads JS code from a file and imports it

Source from the content-addressed store, hash-verified

147
148 // Loads JS code from a file and imports it
149 GJS_JSAPI_RETURN_CONVENTION
150 bool import_file(JSContext* cx, JS::HandleObject module, GFile* file) {
151 Gjs::AutoError error;
152 Gjs::AutoChar script;
153 size_t script_len = 0;
154
155 if (!(g_file_load_contents(file, nullptr, script.out(), &script_len,
156 nullptr, &error)))
157 return gjs_throw_gerror_message(cx, error);
158 g_assert(script);
159
160 Gjs::AutoChar full_path{g_file_get_parse_name(file)};
161 Gjs::AutoChar uri{g_file_get_uri(file)};
162 return evaluate_import(cx, module, script, script_len, full_path, uri);
163 }
164
165 // JSClass operations
166

Callers 1

importMethod · 0.80

Calls 2

gjs_throw_gerror_messageFunction · 0.85
outMethod · 0.45

Tested by

no test coverage detected