Skip to content

Commit

Permalink
fix(cli): 🐛 fixed cli --no-build option
Browse files Browse the repository at this point in the history
No longer deletes build artifacts or tries to finalize (both of which cause a failure).
  • Loading branch information
arctic-hen7 committed Sep 17, 2021
1 parent 78688c1 commit 9890457
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions packages/perseus-cli/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ fn core(dir: PathBuf) -> Result<i32> {
} else if prog_args[0] == "serve" {
// Set up the '.perseus/' directory if needed
prepare(dir.clone())?;
// Delete old build artifacts
delete_artifacts(dir.clone())?;
// Delete old build artifacts if `--no-build` wasn't specified
if !prog_args.contains(&"--no-build".to_string()) {
delete_artifacts(dir.clone())?;
}
let exit_code = serve(dir, &prog_args)?;
Ok(exit_code)
} else if prog_args[0] == "prep" {
Expand Down
10 changes: 5 additions & 5 deletions packages/perseus-cli/src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub fn serve(dir: PathBuf, prog_args: &[String]) -> Result<i32> {
// We can begin building the server in a thread without having to deal with the rest of the build stage yet
let sb_thread = build_server(dir.clone(), &spinners, did_build, Arc::clone(&exec))?;
// Only build if the user hasn't set `--no-build`, handling non-zero exit codes
if !prog_args.contains(&"--no-build".to_string()) {
if did_build {
let (sg_thread, wb_thread) = build_internal(dir.clone(), &spinners, 4)?;
let sg_res = sg_thread
.join()
Expand All @@ -195,10 +195,10 @@ pub fn serve(dir: PathBuf, prog_args: &[String]) -> Result<i32> {
return Ok(sb_res);
}

// This waits for all the threads and lets the spinners draw to the terminal
// spinners.join().map_err(|_| ErrorKind::ThreadWaitFailed)?;
// And now we can run the finalization stage
finalize(&dir.join(".perseus"))?;
// And now we can run the finalization stage (only if `--no-build` wasn't specified)
if did_build {
finalize(&dir.join(".perseus"))?;
}

// Now actually run that executable path
let exit_code = run_server(Arc::clone(&exec), dir.clone(), did_build)?;
Expand Down

0 comments on commit 9890457

Please sign in to comment.