mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
Merge pull request #34 from zephyraft/master
Fix the serialization format error of sourceRoot field in sourcemap.
This commit is contained in:
commit
dc8e1fe70c
@ -77,7 +77,9 @@ public class SourceMapWriter {
|
|||||||
|
|
||||||
// sourceRoot
|
// sourceRoot
|
||||||
if( sourceRoot != null && !sourceRoot.isEmpty() ) {
|
if( sourceRoot != null && !sourceRoot.isEmpty() ) {
|
||||||
appendJsonField( out, "sourceRoot", sourceRoot );
|
out.append( ",\n" );
|
||||||
|
appendJsonField( out, "sourceRoot", "" );
|
||||||
|
appendQuoteString( out, sourceRoot );
|
||||||
}
|
}
|
||||||
|
|
||||||
// the source file names
|
// the source file names
|
||||||
|
@ -27,4 +27,25 @@ public class SourceMapWriterTest {
|
|||||||
"}";
|
"}";
|
||||||
assertEquals( expected, generate.toString() );
|
assertEquals( expected, generate.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void sourceRootNotNull() throws IOException {
|
||||||
|
SourceMapWriter map = new SourceMapWriter( "../../src/main/java/" );
|
||||||
|
|
||||||
|
map.addMapping( new SourceMapping( 0, 1, "Test1.java" ) );
|
||||||
|
map.addMapping( new SourceMapping( 5, 2, "Test1.java" ) );
|
||||||
|
map.addMapping( new SourceMapping( 0, 4, "Test2.java" ) );
|
||||||
|
map.addMapping( new SourceMapping( 5, 9, "Test2.java" ) );
|
||||||
|
|
||||||
|
StringBuilder generate = new StringBuilder();
|
||||||
|
map.generate( generate );
|
||||||
|
String expected = "{\n" +
|
||||||
|
"\"version\":3,\n" +
|
||||||
|
"\"sourceRoot\":\"../../src/main/java/\",\n" +
|
||||||
|
"\"sources\":[\"Test1.java\",\"Test2.java\"],\n" +
|
||||||
|
"\"names\":[],\n" +
|
||||||
|
"\"mappings\":\"AAAA,KACA,LCEA,KAKA;\"\n" +
|
||||||
|
"}";
|
||||||
|
assertEquals( expected, generate.toString() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user