Skip to content

Commit

Permalink
fix: correctly resolve rootDir and outDir options (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonIsaac authored Oct 8, 2024
1 parent 1de9ba4 commit 1d3938f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
23 changes: 12 additions & 11 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(|| {
Expand All @@ -126,6 +126,7 @@ impl OxbuildOptions {
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct TsConfig {
// TODO: tsconfig extends
compiler_options: Option<TsConfigCompilerOptions>,
Expand Down

0 comments on commit 1d3938f

Please sign in to comment.