66import org .utplsql .api .reporter .ReporterFactory ;
77import org .utplsql .cli .ReporterOptions ;
88
9+ import java .nio .file .Path ;
910import java .nio .file .Paths ;
1011import java .sql .Connection ;
1112import java .sql .SQLException ;
@@ -27,15 +28,34 @@ public LocalAssetsCoverageHTMLReporter(String selfType, Object[] attributes) {
2728 public Reporter init (Connection con , CompatibilityProxy compatibilityProxy , ReporterFactory reporterFactory ) throws SQLException {
2829 super .init (con , compatibilityProxy , reporterFactory );
2930
30- if ( options != null && options .outputToFile () )
31- writeReportAssetsTo (Paths .get (getAssetsPath ()));
31+ if ( hasOutputToFile () ) {
32+ writeReportAssetsTo (getPhysicalAssetPath ());
33+ }
3234
3335 return this ;
3436 }
3537
38+ private String getNameOfOutputFile () {
39+ Path outputPath = Paths .get (options .getOutputFileName ());
40+ return outputPath .getName (outputPath .getNameCount ()-1 ).toString ();
41+ }
42+
43+ private Path getPhysicalAssetPath () {
44+ Path outputPath = Paths .get (options .getOutputFileName ());
45+ if ( outputPath .getNameCount () > 1 )
46+ return outputPath .getParent ().resolve (getAssetsPath ());
47+ else
48+ return Paths .get (getAssetsPath ());
49+ }
50+
3651 private void setAssetsPathFromOptions () {
37- if ( options != null && options .outputToFile () )
38- setAssetsPath (options .getOutputFileName ()+"_assets/" );
52+ if ( hasOutputToFile () ) {
53+ setAssetsPath (getNameOfOutputFile () + "_assets/" );
54+ }
55+ }
56+
57+ private boolean hasOutputToFile () {
58+ return (options != null && options .outputToFile ());
3959 }
4060
4161 @ Override
0 commit comments