-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-dependabot
- Loading branch information
Showing
81 changed files
with
3,257 additions
and
1,292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
# Common functions used by the other scripts | ||
|
||
function Check-DirectoryExists { | ||
param ( | ||
[string]$rootDirectory | ||
) | ||
|
||
return Test-Path -Path $rootDirectory -PathType Container | ||
} | ||
|
||
function Find-ReplaceInFiles { | ||
param ( | ||
[string]$rootDirectory, | ||
[string]$sourceString, | ||
[string]$targetString | ||
) | ||
|
||
Get-ChildItem -Recurse -File $rootDirectory | ForEach-Object { | ||
$filePath = $_.FullName | ||
|
||
Find-ReplaceInFile -filePath $filePath -sourceString $sourceString -targetString $targetString | ||
} | ||
|
||
Write-Host "String replacement completed." | ||
} | ||
|
||
function Find-ReplaceInFile { | ||
param ( | ||
[string]$filePath, | ||
[string]$sourceString, | ||
[string]$targetString | ||
) | ||
|
||
# Get the original encoding of the file | ||
$sr = New-Object System.IO.StreamReader($filePath, $true) | ||
[char[]] $buffer = new-object char[] 3 | ||
$sr.Read($buffer, 0, 3) | ||
$originalEncoding = $sr.CurrentEncoding | ||
$sr.Close() | ||
|
||
# Making it simple as we only want to preserve UTF8 encoding | ||
if ( $originalEncoding.BodyName -eq "utf-8" ) { | ||
$fileEncoding = "UTF8" | ||
} | ||
else { | ||
$fileEncoding = "ASCII" | ||
} | ||
|
||
# Read the content of the file using the original encoding | ||
$content = Get-Content -Path $filePath -Raw -Encoding $fileEncoding | ||
|
||
# Perform the replacement | ||
$newContent = $content -replace [regex]::Escape($sourceString), $targetString | ||
|
||
if ($content -ne $newContent) { | ||
Write-Host "Replacing in $filePath" | ||
|
||
# Save the modified content back to the file using the original encoding | ||
Set-Content -Path $filePath -Value $newContent -Encoding $fileEncoding | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.