Skip to content

Commit

Permalink
fix bug where preload("./thing") would become `preload("res://./thi…
Browse files Browse the repository at this point in the history
…ng")` (#23)
  • Loading branch information
bend-n authored Jan 23, 2023
1 parent 06160c5 commit 538ef4b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "godot-package-manager"
version = "1.1.0"
version = "1.1.1"
edition = "2021"
authors = ["bendn <[email protected]>"]
description = "A package manager for godot"
Expand Down
38 changes: 20 additions & 18 deletions src/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,14 @@ impl Package {
}
SCRIPT_LOAD_R
.replace_all(&t, |c: &Captures| {
let m = Path::new(c.get(2).unwrap().as_str());
format!(
"{}load('res://{}')",
if c.get(1).is_some() { "pre" } else { "" },
self.modify_load(m.strip_prefix("res://").unwrap_or(m), cwd, dep_map)
.display()
)
let p = Path::new(c.get(2).unwrap().as_str());
let res = self.modify_load(p.strip_prefix("res://").unwrap_or(p), cwd, dep_map);
let preloaded = if c.get(1).is_some() { "pre" } else { "" };
if res == p {
format!("{preloaded}load('{}')", p.display())
} else {
format!("{preloaded}load('res://{}')", res.display())
}
})
.to_string()
}
Expand Down Expand Up @@ -366,17 +367,18 @@ impl Package {
}
TRES_LOAD_R
.replace_all(&t, |c: &Captures| {
format!(
r#"[ext_resource path="res://{}""#,
self.modify_load(
Path::new(c.get(1).unwrap().as_str())
.strip_prefix("res://")
.expect("TextResource path should be absolute"),
cwd,
dep_map,
)
.display()
)
let p = Path::new(c.get(1).unwrap().as_str());
let res = self.modify_load(
p.strip_prefix("res://")
.expect("TextResource path should be absolute"),
cwd,
dep_map,
);
if res == p {
format!(r#"[ext_resource path="{}""#, p.display())
} else {
format!(r#"[ext_resource path="res://{}""#, res.display())
}
})
.to_string()
}
Expand Down

0 comments on commit 538ef4b

Please sign in to comment.