Skip to content

Commit

Permalink
fix: fix few panics with latest rust-embed, closes #236 (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Nov 23, 2022
1 parent c6ff511 commit 8034aac
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 43 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-cargo.md
@@ -0,0 +1,5 @@
---
"create-tauri-app": "patch"
---

Fix a few panics introduced by some changes in latest `rust-embed` crate versions.
74 changes: 37 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli/Cargo.toml
Expand Up @@ -20,4 +20,4 @@ path = "src/main.rs"
anyhow = "1.0"
dialoguer = "0.10.2"
pico-args = "0.5.0"
rust-embed = { version = "6.5.0", features = [ "compression", "interpolate-folder-path" ] }
rust-embed = { version = "6.5", features = [ "compression", "interpolate-folder-path" ] }
15 changes: 10 additions & 5 deletions packages/cli/src/template.rs
Expand Up @@ -120,6 +120,11 @@ impl<'a> Template {
let manifest = Manifest::parse(&manifest_str)?;

let write_file = |file: &str| -> anyhow::Result<()> {
let fragment_file = Fragments::get(file).unwrap();
if fragment_file.metadata.is_dir() {
return Ok(());
}

let manifest = manifest.clone();

// remove the first component, which is certainly the fragment directory they were in before getting embeded into the binary
Expand Down Expand Up @@ -154,7 +159,7 @@ impl<'a> Template {
_ => &file_name,
};

let mut data = Fragments::get(file).unwrap().data.to_vec();
let mut data = fragment_file.data.to_vec();

// Only modify specific set of files
if [
Expand Down Expand Up @@ -206,8 +211,8 @@ impl<'a> Template {
path::PathBuf::from(e.to_string())
.components()
.next()
.unwrap()
.as_os_str()
.map(|c| c.as_os_str())
.unwrap_or_default()
== "base"
}) {
write_file(&file)?;
Expand All @@ -218,8 +223,8 @@ impl<'a> Template {
path::PathBuf::from(e.to_string())
.components()
.next()
.unwrap()
.as_os_str()
.map(|c| c.as_os_str())
.unwrap_or_default()
== path::PathBuf::from(format!("fragment-{}", self))
}) {
write_file(&file)?;
Expand Down

0 comments on commit 8034aac

Please sign in to comment.