Skip to content

Commit

Permalink
refactored post_build params
Browse files Browse the repository at this point in the history
  • Loading branch information
beborngod committed Jul 17, 2024
1 parent a173188 commit bd9c1c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
16 changes: 6 additions & 10 deletions enunion-helper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
fs::{self, OpenOptions},
io,
io::Write,
path::PathBuf,
path::Path,
process::ExitStatus,
};

Expand All @@ -20,15 +20,15 @@ pub use std::os::windows::process::ExitStatusExt;
/// For TypeScript only.
pub async fn post_build(
enunion_target_path: PathBuf,
definitions_file_path: PathBuf,
enunion_target_path: &Path,
definitions_file_path: &Path,
is_platform: bool,
specified_js: Option<PathBuf>,
specified_js: Option<&Path>,
remove_enunion_gen_folder: bool,
) -> Result<(), ExitStatus> {
let enunion_path = enunion_target_path.join("enunion-generated-ts");

let mut out_ts = match OpenOptions::new().append(true).open(&definitions_file_path) {
let mut out_ts = match OpenOptions::new().append(true).open(definitions_file_path) {
Ok(out_ts) => out_ts,
Err(e) => {
eprintln!("Could not open file {:?}: {:?}", definitions_file_path, e);
Expand All @@ -40,11 +40,7 @@ pub async fn post_build(
Some(
OpenOptions::new()
.append(true)
.open(
specified_js
.clone()
.unwrap_or_else(|| PathBuf::from("index.js")),
)
.open(specified_js.unwrap_or(Path::new("index.js")))
.map_err(|e| {
eprintln!("Could not open JavaScript file: {:?}", e);
ExitStatus::from_raw(1)
Expand Down
6 changes: 3 additions & 3 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ async fn main() -> Result<(), ExitStatus> {
.join("enunion-test");

enunion_helper::post_build(
current_dir.clone(),
current_dir.join("index.d.ts"),
&current_dir.clone(),
&current_dir.join("index.d.ts"),
true,
Some(current_dir.join("index.js")),
Some(&current_dir.join("index.js")),
true,
)
.await?;
Expand Down

0 comments on commit bd9c1c6

Please sign in to comment.