From 21b37376d1a58e82b5001c39660ff116ac5edf21 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sat, 9 Mar 2024 11:59:26 +0000 Subject: [PATCH] Update the warning message when wasm-opt fails Suggest to install binaryen if wasm-opt is not installed --- Sources/CartonCLI/Commands/Bundle.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/CartonCLI/Commands/Bundle.swift b/Sources/CartonCLI/Commands/Bundle.swift index a2ab5b5b..3cca478f 100644 --- a/Sources/CartonCLI/Commands/Bundle.swift +++ b/Sources/CartonCLI/Commands/Bundle.swift @@ -110,9 +110,15 @@ struct Bundle: AsyncParsableCommand { try await optimize(mainWasmPath, outputPath: wasmOutputFilePath, terminal: terminal) } catch { terminal.write( - "Warning: wasm-opt failed to optimize the binary, falling back to the original binary\n", + """ + Warning: wasm-opt failed to optimize the binary, falling back to the original binary. + If you don't have wasm-opt installed, you can install wasm-opt by running `brew install binaryen`, `apt-get install binaryen` or `npm install -g binaryen` + + """, inColor: .yellow) - try localFileSystem.move(from: mainWasmPath, to: wasmOutputFilePath) + if mainWasmPath != wasmOutputFilePath { + try localFileSystem.move(from: mainWasmPath, to: wasmOutputFilePath) + } } } else { if mainWasmPath != wasmOutputFilePath {