Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug where preload("./thing") would become preload("res://./thing") #23

Merged
merged 2 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <bend.n@outlook.com>"]
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