Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
better build logging
Browse files Browse the repository at this point in the history
  • Loading branch information
xortive committed Dec 17, 2020
1 parent a271ffc commit e648284
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ pub fn build_target(target: &Target) -> Result<String, failure::Error> {
match target_type {
TargetType::JavaScript => match &target.builder_config {
None => {
let msg = "JavaScript project found. Skipping unnecessary build!".to_string();
let msg = "Basic JavaScript project found. Skipping unnecessary build!".to_string();
Ok(msg)
}
Some(config) => {
if let Some(mut command) = config.build_command() {
StdErr::working(
format!("Running {}", config.build_command.as_ref().unwrap()).as_ref(),
);
command.spawn()?.wait()?.success();
Ok(String::from("Build completed successfully!"))
} else {
Expand All @@ -41,6 +44,7 @@ pub fn build_target(target: &Target) -> Result<String, failure::Error> {
let command = command(&args, &binary_path);
let command_name = format!("{:?}", command);

StdErr::working("Compiling your project to WebAssembly...");
commands::run(command, &command_name)?;
let msg = "Build succeeded".to_string();
Ok(msg)
Expand All @@ -59,8 +63,6 @@ pub fn build_target(target: &Target) -> Result<String, failure::Error> {
}

pub fn command(args: &[&str], binary_path: &PathBuf) -> Command {
StdErr::working("Compiling your project to WebAssembly...");

let mut c = if cfg!(target_os = "windows") {
let mut c = Command::new("cmd");
c.arg("/C");
Expand Down
3 changes: 1 addition & 2 deletions src/settings/toml/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const SRC_DIR: &str = "src";
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Builder {
#[serde(alias = "build-command")]
build_command: Option<String>,
pub build_command: Option<String>,
#[serde(default = "output_dir")]
pub output_dir: PathBuf,
pub upload_format: ScriptFormat,
Expand Down
5 changes: 2 additions & 3 deletions src/watch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ pub fn watch_and_build(
) -> Result<(), failure::Error> {
let target_type = &target.target_type;
let builder_config = target.builder_config.clone();
// TODO(cleanup): better way to please the compiler so the js watcher thread can own it's target?
let jstarget = target.clone();
match target_type {
TargetType::JavaScript => {
let target = target.clone();
thread::spawn::<_, Result<(), failure::Error>>(move || {
let (watcher_tx, watcher_rx) = mpsc::channel();
let mut watcher = notify::watcher(watcher_tx, Duration::from_secs(1))?;
Expand Down Expand Up @@ -71,7 +70,7 @@ pub fn watch_and_build(
StdOut::info("Ignoring stale first change");
continue;
} else {
let output = build_target(&jstarget).unwrap();
let output = build_target(&target).unwrap();
StdOut::success(&format!("{}\nUploading...", output));
}
}
Expand Down

0 comments on commit e648284

Please sign in to comment.