From 1d3938f6edc85d2e3b82cf3760142b7fb2f5f6ad Mon Sep 17 00:00:00 2001 From: Don Isaac Date: Tue, 8 Oct 2024 15:40:58 -0400 Subject: [PATCH] fix: correctly resolve rootDir and outDir options (#32) --- Cargo.toml | 5 +++-- src/options.rs | 23 ++++++++++++----------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4c2ea0a..4a7f89d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,9 +50,10 @@ opt-level = 1 # defaults: https://doc.rust-lang.org/cargo/reference/profiles.html#release [profile.release] codegen-units = 4 -strip = "symbols" +debug = false # set to `true` for debugging +strip = "symbols" # set to `false` for debugging lto = "thin" -panic = "abort" +panic = "abort" # set to `unwind` for backtraces # The profile that 'cargo dist' will build with [profile.dist] diff --git a/src/options.rs b/src/options.rs index 2746ccc..bf46ee9 100644 --- a/src/options.rs +++ b/src/options.rs @@ -71,7 +71,6 @@ impl OxbuildOptions { debug!("Using default src directory"); let src = root.join("src").to_path_buf(); if !src.exists() { - trace!("Creating src directory at '{}'", src.display()); return Err(Report::msg("src directory does not exist. Please explicitly provide a path to your source files.".to_string())); } src @@ -89,22 +88,23 @@ impl OxbuildOptions { "Resolving outDir from tsconfig.json: '{}'", out_dir.display() ); - root.resolve(out_dir) + root.join(out_dir) } else { debug!("Using default dist directory"); - let dist = root.join("dist").to_path_buf(); - if !dist.exists() { - trace!("Creating dist directory at '{}'", dist.display()); - fs::create_dir(&dist).into_diagnostic()?; - } - // TODO: clean dist dir? - dist + root.join("dist").to_path_buf() }; + // TODO: clean dist dir? + if !dist.exists() { + trace!("Creating dist directory at '{}'", dist.display()); + fs::create_dir_all(&dist).into_diagnostic()?; + } assert!(dist.is_dir()); // FIXME: handle errors + let dist = dist + .canonicalize() + .into_diagnostic() + .wrap_err("Failed to canonicalize dist directory")?; trace!("dist directory: '{}'", dist.display()); - // let strip_internal = co.and_then(|co| co.) - // no tsconfig means they're using JavaScript. We can't emit .d.ts files in that case. let isolated_declarations = co.and_then(|co| { co.isolated_declarations.unwrap_or(false).then(|| { @@ -126,6 +126,7 @@ impl OxbuildOptions { } #[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] struct TsConfig { // TODO: tsconfig extends compiler_options: Option,