Browse Source

fix(bundler) throw error when resource, external bin or icon not… (#470)

Lucas Fernandes Nogueira 5 years ago
parent
commit
6ba7fe4096

+ 0 - 1
cli/tauri-bundler/src/bundle/deb_bundle.rs

@@ -117,7 +117,6 @@ fn generate_bootstrap_file(settings: &Settings, data_dir: &Path) -> crate::Resul
   let bootstrap_file_name = format!("__{}-bootstrapper", bin_name);
   let bootstrapper_file_path = bin_dir.join(bootstrap_file_name.clone());
   let bootstrapper_file = &mut common::create_file(&bootstrapper_file_path)?;
-  println!("{:?}", bootstrapper_file_path);
   write!(
     bootstrapper_file,
     "#!/usr/bin/env sh

+ 15 - 1
cli/tauri-bundler/src/bundle/settings.rs

@@ -575,7 +575,7 @@ fn add_external_bin(bundle_settings: BundleSettings) -> crate::Result<BundleSett
       }
       Some(win_paths)
     }
-    None => Some(vec![String::from("")]),
+    None => Some(vec![]),
   };
 
   Ok(BundleSettings {
@@ -589,6 +589,8 @@ pub struct ResourcePaths<'a> {
   glob_iter: Option<glob::Paths>,
   walk_iter: Option<walkdir::IntoIter>,
   allow_walk: bool,
+  current_pattern: Option<String>,
+  current_pattern_is_valid: bool
 }
 
 impl<'a> ResourcePaths<'a> {
@@ -598,6 +600,8 @@ impl<'a> ResourcePaths<'a> {
       glob_iter: None,
       walk_iter: None,
       allow_walk,
+      current_pattern: None,
+      current_pattern_is_valid: false,
     }
   }
 }
@@ -617,6 +621,7 @@ impl<'a> Iterator for ResourcePaths<'a> {
           if path.is_dir() {
             continue;
           }
+          self.current_pattern_is_valid = true;
           return Some(Ok(path.to_path_buf()));
         }
       }
@@ -637,11 +642,20 @@ impl<'a> Iterator for ResourcePaths<'a> {
               return Some(Err(crate::Error::from(msg)));
             }
           }
+          self.current_pattern_is_valid = true;
           return Some(Ok(path));
+        } else {
+          if let Some(current_path) = &self.current_pattern {
+            if !self.current_pattern_is_valid {
+              return Some(Err(crate::Error::from(format!("Path matching '{}' not found", current_path))));
+            }
+          }
         }
       }
       self.glob_iter = None;
       if let Some(pattern) = self.pattern_iter.next() {
+        self.current_pattern = Some(pattern.to_string());
+        self.current_pattern_is_valid = false;
         let glob = match glob::glob(pattern) {
           Ok(glob) => glob,
           Err(error) => return Some(Err(crate::Error::from(error))),