File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed
crates/spidermonkey-embedding-splicer/src Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -70,10 +70,11 @@ fn map_core_fn(cfn: &bindgen::CoreFn) -> CoreFn {
7070 }
7171}
7272
73- fn parse_wit ( path : & Path ) -> Result < ( Resolve , PackageId ) > {
73+ fn parse_wit ( path : impl AsRef < Path > ) -> Result < ( Resolve , PackageId ) > {
7474 let mut resolve = Resolve :: default ( ) ;
75+ let path = path. as_ref ( ) ;
7576 let id = if path. is_dir ( ) {
76- resolve. push_dir ( & path) ?. 0
77+ resolve. push_dir ( & path) . context ( "failed to push dir" ) ?. 0
7778 } else {
7879 let contents =
7980 std:: fs:: read ( & path) . with_context ( || format ! ( "failed to read file {path:?}" ) ) ?;
Original file line number Diff line number Diff line change @@ -33,15 +33,19 @@ pub fn splice_bindings(
3333 wit_source : Option < String > ,
3434 debug : bool ,
3535) -> Result < SpliceResult , String > {
36- let ( mut resolve, id) = if let Some ( wit_source) = wit_source {
37- let mut resolve = Resolve :: default ( ) ;
38- let path = PathBuf :: from ( "component.wit" ) ;
39- let id = resolve
40- . push_str ( & path, & wit_source)
41- . map_err ( |e| e. to_string ( ) ) ?;
42- ( resolve, id)
43- } else {
44- parse_wit ( & PathBuf :: from ( wit_path. unwrap ( ) ) ) . map_err ( |e| format ! ( "{:?}" , e) ) ?
36+ let ( mut resolve, id) = match ( wit_source, wit_path) {
37+ ( Some ( wit_source) , _) => {
38+ let mut resolve = Resolve :: default ( ) ;
39+ let path = PathBuf :: from ( "component.wit" ) ;
40+ let id = resolve
41+ . push_str ( & path, & wit_source)
42+ . map_err ( |e| e. to_string ( ) ) ?;
43+ ( resolve, id)
44+ }
45+ ( _, Some ( wit_path) ) => parse_wit ( & wit_path) . map_err ( |e| format ! ( "{:?}" , e) ) ?,
46+ ( None , None ) => {
47+ return Err ( "neither wit source nor path have been specified" . into ( ) ) ;
48+ }
4549 } ;
4650
4751 let world = resolve
You can’t perform that action at this time.
0 commit comments