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

Commit

Permalink
fix #255: stop cleaning webpack build artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
EverlastingBugstopper committed Jul 8, 2019
1 parent 04b8956 commit 8ca8589
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 21 deletions.
14 changes: 1 addition & 13 deletions src/commands/build/wranglerjs/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use std::fs::File;
use std::io::prelude::*;
use std::path::{Path, PathBuf};

use log::info;

use crate::commands::build::wranglerjs::output::WranglerjsOutput;
use crate::settings::binding::Binding;
use crate::settings::metadata;
Expand Down Expand Up @@ -57,12 +55,6 @@ impl Bundle {
let mut metadata_file = File::create(self.metadata_path())?;
metadata_file.write_all(metadata.as_bytes())?;

// cleanup {Webpack} dist, if specified.
if let Some(dist_to_clean) = &wranglerjs_output.dist_to_clean {
info!("Remove {}", dist_to_clean);
fs::remove_dir_all(dist_to_clean).expect("could not clean Webpack dist.");
}

Ok(())
}

Expand Down Expand Up @@ -150,7 +142,7 @@ mod tests {
let wranglerjs_output = WranglerjsOutput {
errors: vec![],
script: "".to_string(),
dist_to_clean: None,

wasm: None,
};
let bundle = Bundle::new_at(out.clone());
Expand All @@ -171,7 +163,6 @@ mod tests {
let wranglerjs_output = WranglerjsOutput {
errors: vec![],
script: "foo".to_string(),
dist_to_clean: None,
wasm: None,
};
let bundle = Bundle::new_at(out.clone());
Expand All @@ -190,7 +181,6 @@ mod tests {
errors: vec![],
script: "".to_string(),
wasm: Some("abc".to_string()),
dist_to_clean: None,
};
let bundle = Bundle::new_at(out.clone());

Expand All @@ -208,7 +198,6 @@ mod tests {
errors: vec![],
script: "".to_string(),
wasm: Some("abc".to_string()),
dist_to_clean: None,
};
let bundle = Bundle::new_at(out.clone());

Expand All @@ -231,7 +220,6 @@ mod tests {
errors: vec!["a".to_string(), "b".to_string()],
script: "".to_string(),
wasm: None,
dist_to_clean: None,
};
assert!(wranglerjs_output.has_errors());
assert!(wranglerjs_output.get_errors() == "a\nb");
Expand Down
2 changes: 1 addition & 1 deletion src/commands/build/wranglerjs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn run_build(project: &Project) -> Result<(), failure::Error> {
serde_json::from_str(&output).expect("could not parse wranglerjs output");

if wranglerjs_output.has_errors() {
message::user_error(&format!("{}", wranglerjs_output.get_errors()));
message::user_error(wranglerjs_output.get_errors().as_str());
failure::bail!("Webpack returned an error");
}

Expand Down
6 changes: 0 additions & 6 deletions src/commands/build/wranglerjs/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ use std::io::prelude::*;
pub struct WranglerjsOutput {
pub wasm: Option<String>,
pub script: String,
// {wranglerjs} will send us the path to the {dist} directory that {Webpack}
// used; it's tedious to remove a directory with content in JavaScript so
// let's do it in Rust!
pub dist_to_clean: Option<String>,
// Errors emited by {wranglerjs}, if any
pub errors: Vec<String>,
}
Expand Down Expand Up @@ -58,7 +54,6 @@ mod tests {
let wranglerjs_output = WranglerjsOutput {
errors: vec![],
script: "aaaa".to_string(),
dist_to_clean: None,
wasm: None,
};

Expand All @@ -70,7 +65,6 @@ mod tests {
let wranglerjs_output = WranglerjsOutput {
errors: vec![],
script: "".to_string(),
dist_to_clean: None,
wasm: Some("abc".to_string()),
};

Expand Down
1 change: 0 additions & 1 deletion wranglerjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ compiler.run((err, stats) => {
const bundle = {
wasm: null,
script: "",
dist_to_clean: fullConfig.output.path,
errors: jsonStats.errors
};

Expand Down

0 comments on commit 8ca8589

Please sign in to comment.