From b5a1b0d90f947524923a2a5ae293c257731e35ee Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Tue, 30 Mar 2021 12:16:49 +0100 Subject: [PATCH] Check wasm optimized output file exists (#243) * Check wasm optimized output file exists * Fmt * Add expected optimized file to error * Use display for path --- src/cmd/build.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index fac09452d..f2e9bb036 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -317,6 +317,13 @@ fn optimize_wasm( optimization_passes, )?; + if !dest_optimized.exists() { + return Err(anyhow::anyhow!( + "Optimization failed, optimized wasm output file `{}` not found.", + dest_optimized.display() + )); + } + let original_size = metadata(&crate_metadata.dest_wasm)?.len() as f64 / 1000.0; let optimized_size = metadata(&dest_optimized)?.len() as f64 / 1000.0;