diff --git a/CHANGELOG.md b/CHANGELOG.md index 340c2386..fea578c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ changelog This changelog follows the patterns described here: https://keepachangelog.com/en/1.0.0/. ## Unreleased +### fixed +- Closed [#82](https://github.com/thedodd/trunk/issues/82): Remove the hardcoded Unix (`/`) path separator from the code and convert Windows NT UNC path to its simplified alternative before passing to `cargo metadata` command to prevent issues with Rust package collisions and writing `index.html` file. ## 0.7.2 ### fixed diff --git a/Cargo.lock b/Cargo.lock index 151040ca..bf270005 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -722,6 +722,12 @@ dependencies = [ "dtoa", ] +[[package]] +name = "dunce" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2641c4a7c0c4101df53ea572bffdc561c146f6c2eb09e4df02bc4811e3feeb4" + [[package]] name = "encode_unicode" version = "0.3.6" @@ -2466,6 +2472,7 @@ dependencies = [ "async-std", "cargo_metadata", "console 0.12.0", + "dunce", "envy", "fs_extra", "futures", diff --git a/Cargo.toml b/Cargo.toml index 490d59ef..e429aba2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ async-process = "0.1.1" async-std = { version="1.6.3", features=["attributes", "unstable"] } cargo_metadata = "0.11.3" console = "0.12.0" +dunce = "1.0.1" envy = "0.4.1" fs_extra = "1.2.0" futures = "0.3.5" diff --git a/src/config/manifest.rs b/src/config/manifest.rs index 381ca5b5..fca8f098 100644 --- a/src/config/manifest.rs +++ b/src/config/manifest.rs @@ -19,7 +19,7 @@ impl CargoMetadata { // Create a new instance from the Cargo.toml at the given path. pub async fn new(manifest: &Path) -> Result { let mut cmd = MetadataCommand::new(); - cmd.manifest_path(manifest); + cmd.manifest_path(dunce::simplified(manifest)); let metadata = spawn_blocking(move || cmd.exec()).await?; let package = metadata .root_package() diff --git a/src/pipelines/html.rs b/src/pipelines/html.rs index fe4eb598..c46a4e74 100644 --- a/src/pipelines/html.rs +++ b/src/pipelines/html.rs @@ -109,9 +109,9 @@ impl HtmlPipeline { // Assemble a new output index.html file. let output_html = target_html.html(); // TODO: prettify this output. - fs::write(format!("{}/index.html", self.cfg.dist.display()), output_html.as_bytes()) + fs::write(self.cfg.dist.join("index.html"), output_html.as_bytes()) .await - .context("error writing finalized HTML output")?; + .context("error writing finalized HTML output")?; // TODO: show also error details (in a verbose mode?) Ok(()) }