mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-08-04 03:48:41 -04:00

Former-commit-id: 8dfb94e6e59e8b616f3df9b7b9520009249ec620 [formerly e9fcabf193434fd1b64d3acdad2eece23873b28f] [formerly 8314aad2f670bb3d19036a996e900628d4176999] [formerly 2da443b9e89fa446bc2ef4535a117727da84ab54 [formerly dc543763283af6879e0be1d97a6ef1929a99f05c [formerly 07ec84d2a5fa2e488791997009980855d76aa8f1]]] Former-commit-id: 8f9b2e0748edf1f2579bc3f4c575df4927b7a6d0 [formerly 455540b0c9e480cf8464ed22a68732f8169b96ec [formerly 5aa695efe85534a9a73c80c491aa4fbcb811b598]] Former-commit-id: 60964ac2ef01638e276425d869c81168f95931b6 [formerly d55eb6c51fa61a0d86c858d8e2bd37359a421fc5] Former-commit-id: 6d2b8875109201aae615d8b5dc1e42389e878ba6
36 lines
1.1 KiB
PowerShell
36 lines
1.1 KiB
PowerShell
param (
|
|
[string]$filename = "",
|
|
[switch]$nobom = $false,
|
|
[switch]$addbom = $false
|
|
)
|
|
|
|
# Deal with cases where no directory is entered
|
|
if ($filename -eq "") {
|
|
$filename = Read-Host "Enter the directory for processing: "
|
|
}
|
|
" "
|
|
ls -r -name $filename -Include @('*.js','*.css','*.html')
|
|
if ($nobom) {
|
|
$input = Read-Host "`nAll the above files will have the BOM (if any) removed!`nProceed? (Y/N)"
|
|
} else {
|
|
$input = Read-Host "`nAll the above files will have a BOM added (if necessary)!`nProceed? (Y/N)"
|
|
}
|
|
if ($input -eq "Y") {
|
|
if ($nobom) {
|
|
"Removing Byte Order Mark ..."
|
|
ls -r $filename -Include @('*.js','*.css','*.html') | % { [System.IO.File]::WriteAllLines($_.FullName, ((Get-Content $_.FullName) -replace "^\xEF\xBB\xBF", ""))}
|
|
} else {
|
|
"Adding Byte Order Mark ..."
|
|
ls -r $filename -Include @('*.js','*.css','*.html') | % {
|
|
$document = Get-Content -encoding "UTF8" $_.FullName
|
|
if ($document -match "^(?!\xEF\xBB\xBF)") {
|
|
$document | Set-Content -encoding "utf8BOM" $_.FullName
|
|
}
|
|
}
|
|
}
|
|
"Done."
|
|
} else {
|
|
"Operation cancelled!"
|
|
}
|
|
|