print also *.js file if only *.wat was compiled

This commit is contained in:
Volker Berlin 2020-06-21 13:30:07 +02:00
parent 6b309dac9f
commit e6be6a66ec

View File

@ -196,17 +196,23 @@ public class WasmRule extends TemporaryFolder {
protected void after() {
if( failed ) {
for( File wasmFile : compiledFiles.values() ) {
File jsFile;
if( wasmFile.getName().endsWith( ".wasm" ) ) {
File jsFile = new File( wasmFile.toString() + ".js" );
if( jsFile.isFile() ) {
try {
System.out.println( new String( Files.readAllBytes( jsFile.toPath() ), StandardCharsets.UTF_8 ) );
System.out.println();
} catch( IOException e ) {
e.printStackTrace();
}
break;
jsFile = new File( wasmFile.toString() + ".js" );
} else if( wasmFile.getName().endsWith( ".wat" ) ) {
String name = wasmFile.toString();
jsFile = new File( name.substring( 0, name.length() - 4 ) + ".wasm.js" );
} else {
continue;
}
if( jsFile.isFile() ) {
try {
System.out.println( new String( Files.readAllBytes( jsFile.toPath() ), StandardCharsets.UTF_8 ) );
System.out.println();
} catch( IOException e ) {
e.printStackTrace();
}
break;
}
}
System.out.println( textCompiled );