Skip to content

Commit

Permalink
feat: resolve ~ paths (#875)
Browse files Browse the repository at this point in the history
* feat: resolve `~` paths
  • Loading branch information
simbleau authored Sep 13, 2024
1 parent 47becdc commit 2352cde
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 11 deletions.
100 changes: 97 additions & 3 deletions Cargo.lock

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

11 changes: 4 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "Build, bundle & ship your Rust WASM application to the web."
license = "MIT/Apache-2.0"
authors = [
"Anthony Dodd <[email protected]>",
"Jens Reimann <[email protected]>"
"Jens Reimann <[email protected]>",
]
repository = "https://github.com/trunk-rs/trunk"
readme = "README.md"
Expand All @@ -33,6 +33,7 @@ directories = "5"
dunce = "1"
flate2 = "1"
futures-util = { version = "0.3", default-features = false, features = ["sink"] }
homedir = "0.3.3"
htmlescape = "0.3.1"
humantime = "2"
humantime-serde = "1"
Expand Down Expand Up @@ -111,11 +112,7 @@ native-tls = [
]

# enable the update check on startup
update_check = [
"crates_io_api"
]
update_check = ["crates_io_api"]

# enable vendoring on crates supporting that
vendored = [
"openssl?/vendored",
]
vendored = ["openssl?/vendored"]
15 changes: 14 additions & 1 deletion src/config/rt/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,20 @@ fn absolute_path_if_some(
file_description: &str,
) -> anyhow::Result<Option<PathBuf>, anyhow::Error> {
match maybe_path {
Some(path) => Ok(Some(absolute_path(path, file_description)?)),
Some(path) => {
let path = if path.to_string_lossy().contains('~') {
let home_path = homedir::my_home()
.context("home directory path not available")?
.context("no home directory")?;
let new_path = path
.to_string_lossy()
.replace('~', &home_path.to_string_lossy());
PathBuf::from(new_path)
} else {
path
};
Ok(Some(absolute_path(path, file_description)?))
}
None => Ok(None),
}
}
Expand Down

0 comments on commit 2352cde

Please sign in to comment.