33 [String ]$config
44)
55
6- . (Resolve-Path " $PSScriptRoot \src\config.ps1" ).Path
7- . (Resolve-Path " $PSScriptRoot \src\assets.ps1" ).Path
8- . (Resolve-Path " $PSScriptRoot \src\render.ps1" ).Path
9- . (Resolve-Path " $PSScriptRoot \src\xml-reader.ps1" ).Path
10- . (Resolve-Path " $PSScriptRoot \src\templates\templates.ps1" ).Path
11-
12- $version = Get-Content - Raw - Path (Resolve-Path " $PSScriptRoot \version" ).Path
13- Write-Host " constUP JaCoCo XML to HTML Code Coverage Report Generator $version "
14- Write-Host " =========="
15- Write-Host " "
16-
17- Write-Host " Loading configuration..."
18- Load- Config - configFileLocation $config
19- $xmlFile = $Global :jacocoxml2htmlConfig.xml_file
20- $destinationDirectory = $Global :jacocoxml2htmlConfig.destination_directory
21- $sourcesDirectory = $Global :jacocoxml2htmlConfig.sources_directory
22- Write-Host " Configuration loaded."
23-
24- Write-Host ' Checking XML file...'
25- if (-Not (Test-Path $xmlFile )) {
26- Write-Error " XML file $xmlFile either does not exist or can not be read."
27- exit 1
28- }
29- Write-Host ' XML file is present.'
30-
31- Write-Host ' Checking destination directory...'
32- if (-Not (Test-Path $destinationDirectory )) {
33- try {
34- New-Item - ItemType Directory - Path $destinationDirectory - Force > $null
35- }
36- catch
37- {
38- Write-Error " Invalid destination directory or directory can not be created."
39- exit 1
40- }
41- } else {
42- if ((Get-ChildItem - Path $destinationDirectory | Measure-Object ).Count -ne 0 ) {
43- throw " Destination directory is not empty."
44- exit 1
45- }
46- }
47- Write-Host ' Destination directory is ready.'
48-
49- Write-Host ' Creating base template assets...'
50- try {
51- Copy-Assets - destinationDirectory $destinationDirectory
52- Set-Content - Path " $destinationDirectory /index.html" - Value " "
53- } catch {
54- Write-Error " There was a problem while trying to write base template files in: $destinationDirectory "
55- exit 1
56- }
57- Write-Host ' Base template assets are ready.'
58-
59- Write-Host ' Preloading templates...'
60- $preloadedTemplates = Preload- Templates
61- Write-Host ' Templates are loaded.'
62-
63- Write-Host ' Rendering files...'
64- $xmlObject = Read-XML - filePath $xmlFile
65- Render- Files `
66- - destinationDirectory $destinationDirectory `
67- - xmlObject $xmlObject `
68- - preloadedTemplates $preloadedTemplates `
69- - sourcesDirectory $sourcesDirectory
70- Write-Host ' All files are rendered.'
71- Write-Host ' '
72-
73- Write-Host " HTML coverage report has been successfully generated."
6+ & .\src\main.ps1 - config $config
0 commit comments