mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-29 21:34:50 +00:00
Add support for specifying include paths to the nodejs API
I tried passing this as a component of the file name (uri style with a query), but nodejs wants only valid paths for require() calls. So instead this uses simply an environment variable.
This commit is contained in:
parent
a178b9b2e3
commit
0aaa163058
1 changed files with 7 additions and 1 deletions
|
@ -25,8 +25,14 @@ scoped_tls_hkt::scoped_thread_local!(static GLOBAL_CONTEXT:
|
|||
fn load(mut cx: FunctionContext) -> JsResult<JsValue> {
|
||||
let path = cx.argument::<JsString>(0)?.value();
|
||||
let path = std::path::Path::new(path.as_str());
|
||||
let include_paths = match std::env::var_os("SIXTYFPS_INCLUDE_PATH") {
|
||||
Some(paths) => {
|
||||
std::env::split_paths(&paths).filter(|path| !path.as_os_str().is_empty()).collect()
|
||||
}
|
||||
None => vec![],
|
||||
};
|
||||
let source = std::fs::read_to_string(&path).or_else(|e| cx.throw_error(e.to_string()))?;
|
||||
let c = match sixtyfps_interpreter::load(source, &path, &[]) {
|
||||
let c = match sixtyfps_interpreter::load(source, &path, &include_paths) {
|
||||
Ok(c) => c,
|
||||
Err(diag) => {
|
||||
diag.print();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue