@@ -39,19 +39,39 @@ jobs:
39
39
# Copy necessary files into the dist directory
40
40
Copy-Item -Recurse -Path "temp/*" -Destination "dist" -Force
41
41
42
+ - name : Backup JS files before modifying
43
+ run : |
44
+ # Create a backup of the original JS files
45
+ Copy-Item -Recurse -Path "dist\assets\*.js" -Destination "dist\assets\backup" -Force
46
+
42
47
- name : Update paths in HTML and JS files
43
48
run : |
44
49
# Update paths in HTML files
45
50
Get-ChildItem dist\*.html | ForEach-Object {
46
- (Get-Content $_.FullName) `
51
+ $filePath = $_.FullName
52
+ $content = Get-Content $filePath
53
+ $newContent = $content `
47
54
-replace 'src="(/assets/)', 'src="./assets/' `
48
- -replace 'href="(/assets/)', 'href="./assets/' | Set-Content $_.FullName
55
+ -replace 'href="(/assets/)', 'href="./assets/'
56
+ Set-Content -Path $filePath -Value $newContent
57
+
58
+ # Log the changes for debugging
59
+ if ($newContent -ne $content) {
60
+ Write-Host "Updated asset paths in $filePath"
61
+ }
49
62
}
50
63
51
64
# Update paths in JS files inside the assets folder
52
65
Get-ChildItem dist\assets\*.js | ForEach-Object {
53
- (Get-Content $_.FullName) `
54
- -replace '("/assets/)', '("./assets/' | Set-Content $_.FullName
66
+ $filePath = $_.FullName
67
+ $content = Get-Content $filePath
68
+ $newContent = $content -replace '("/assets/)', '("./assets/'
69
+
70
+ # Log the changes for debugging
71
+ if ($newContent -ne $content) {
72
+ Write-Host "Updating asset paths in $filePath"
73
+ }
74
+ Set-Content -Path $filePath -Value $newContent
55
75
}
56
76
57
77
- name : List files in the dist directory after copying
0 commit comments