Skip to content

Commit

Permalink
feat(cli): added support for cargo colors
Browse files Browse the repository at this point in the history
  • Loading branch information
arctic-hen7 committed Jan 5, 2023
1 parent e8f000d commit 513b1cf
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 8 deletions.
5 changes: 4 additions & 1 deletion packages/perseus-cli/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ pub fn build_internal(
vec![
("PERSEUS_ENGINE_OPERATION", "build"),
("CARGO_TARGET_DIR", "dist/target_engine"),
("RUSTFLAGS", "--cfg=engine")
("RUSTFLAGS", "--cfg=engine"),
("CARGO_TERM_COLOR", "always")
]
)?);

Expand Down Expand Up @@ -137,11 +138,13 @@ pub fn build_internal(
vec![
("CARGO_TARGET_DIR", "dist/target_wasm"),
("RUSTFLAGS", &wasm_release_rustflags),
("CARGO_TERM_COLOR", "always"),
]
} else {
vec![
("CARGO_TARGET_DIR", "dist/target_wasm"),
("RUSTFLAGS", "--cfg=client"),
("CARGO_TERM_COLOR", "always"),
]
}
)?);
Expand Down
9 changes: 6 additions & 3 deletions packages/perseus-cli/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ fn cargo_check(
// and the browser simultaneously (different targets, so no
// commonalities gained by one directory)
("CARGO_TARGET_DIR", "dist/target_engine"),
("RUSTFLAGS", "--cfg=engine")
("RUSTFLAGS", "--cfg=engine"),
("CARGO_TERM_COLOR", "always")
]
)?);

Expand All @@ -143,7 +144,8 @@ fn cargo_check(
&browser_msg,
vec![
("CARGO_TARGET_DIR", "dist/target_wasm"),
("RUSTFLAGS", "--cfg=client")
("RUSTFLAGS", "--cfg=client"),
("CARGO_TERM_COLOR", "always")
]
)?);

Expand Down Expand Up @@ -185,7 +187,8 @@ fn run_static_generation(
vec![
("PERSEUS_ENGINE_OPERATION", "build"),
("CARGO_TARGET_DIR", "dist/target_engine"),
("RUSTFLAGS", "--cfg=engine")
("RUSTFLAGS", "--cfg=engine"),
("CARGO_TERM_COLOR", "always")
]
)?);

Expand Down
1 change: 1 addition & 0 deletions packages/perseus-cli/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub fn run_cmd(
.args([shell_param, &cmd])
.envs(envs)
.current_dir(dir)
// A pipe is set for stdio
.output()
.map_err(|err| ExecutionError::CmdExecFailed { cmd, source: err })?;

Expand Down
5 changes: 4 additions & 1 deletion packages/perseus-cli/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ pub fn export_internal(
vec![
("PERSEUS_ENGINE_OPERATION", "export"),
("CARGO_TARGET_DIR", "dist/target_engine"),
("RUSTFLAGS", "--cfg=engine")
("RUSTFLAGS", "--cfg=engine"),
("CARGO_TERM_COLOR", "always")
]
)?);

Expand Down Expand Up @@ -248,11 +249,13 @@ pub fn export_internal(
vec![
("CARGO_TARGET_DIR", "dist/target_wasm"),
("RUSTFLAGS", &wasm_release_rustflags),
("CARGO_TERM_COLOR", "always"),
]
} else {
vec![
("CARGO_TARGET_DIR", "dist/target_wasm"),
("RUSTFLAGS", "--cfg=client"),
("CARGO_TERM_COLOR", "always"),
]
}
)?);
Expand Down
1 change: 1 addition & 0 deletions packages/perseus-cli/src/export_error_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub fn export_error_page(
("PERSEUS_ENGINE_OPERATION", "export_error_page"),
("CARGO_TARGET_DIR", "dist/target_engine"),
("RUSTFLAGS", "--cfg=engine"),
("CARGO_TERM_COLOR", "always"),
],
|| {},
)?;
Expand Down
5 changes: 4 additions & 1 deletion packages/perseus-cli/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ impl Tools {
&workspace_root,
&lf_spinner,
&lf_msg,
vec![("RUSTFLAGS", "--cfg=engine")],
vec![
("RUSTFLAGS", "--cfg=engine"),
("CARGO_TERM_COLOR", "always"),
],
)
.map_err(|err| InstallError::LockfileGenerationFailed { source: err })?;
if exit_code != 0 {
Expand Down
3 changes: 2 additions & 1 deletion packages/perseus-cli/src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ fn build_server(
&sb_msg,
vec![
("CARGO_TARGET_DIR", "dist/target_engine"),
("RUSTFLAGS", "--cfg=engine")
("RUSTFLAGS", "--cfg=engine"),
("CARGO_TERM_COLOR", "always")
]
)?);

Expand Down
2 changes: 2 additions & 0 deletions packages/perseus-cli/src/snoop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use crate::parse::{Opts, SnoopServeOpts};
use crate::{errors::*, get_user_crate_name};
use std::path::PathBuf;

// NOTE: Cargo colors are left to the terminal directly here.

/// Runs static generation processes directly so the user can see detailed logs.
/// This is commonly used for allowing users to see `dbg!` and the like in their
/// builder functions.
Expand Down
3 changes: 2 additions & 1 deletion packages/perseus-cli/src/tinker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ pub fn tinker_internal(
vec![
("PERSEUS_ENGINE_OPERATION", "tinker"),
("CARGO_TARGET_DIR", "dist/target_engine"),
("RUSTFLAGS", "--cfg=engine")
("RUSTFLAGS", "--cfg=engine"),
("CARGO_TERM_COLOR", "always")
]
)?);

Expand Down

0 comments on commit 513b1cf

Please sign in to comment.