Guest User

Automatic add-on disconnect() repair

a guest
Jan 2nd, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #INSTRUCTIONS
  2. # Place all add-ons to be fixed in a folder called "input".
  3. # Run this script from "input"'s parent directory.
  4. # They will be repaired and placed in "output".
  5.  
  6. #REQUIRES
  7. # The "PowerShell Community Extensions": https://pscx.codeplex.com/
  8.  
  9. #UNZIP ALL
  10. echo("1) Unzipping files.`n");
  11. Get-ChildItem ".\input\" -Filter *.zip | `
  12. Foreach-Object{
  13.     $name = $_.BaseName
  14.     if(!(Test-Path ".\temp\$name"))
  15.     {
  16.         mkdir ".\temp\$name"
  17.         expand-archive -Path $_.FullName -OutputPath ".\temp\$name"
  18.     }
  19.     else
  20.     {
  21.         echo("Skip $name");
  22.     }
  23. }
  24.  
  25. #REPAIR
  26. echo("2) Repairing files.`n");
  27. $configFiles= Get-ChildItem .\temp *.cs -rec
  28. foreach ($file in $configFiles)
  29. {
  30.     (Get-Content $file.PSPath) | Foreach-Object{$_ -replace "function disconnect\(\)", "function disconnect(%bool)"} | Set-Content $file.PSPath
  31.     (Get-Content $file.PSPath) | Foreach-Object{$_ -replace "parent::disconnect\(\)", "parent::disconnect(%bool)"} | Set-Content $file.PSPath
  32.     (Get-Content $file.PSPath) | Foreach-Object{$_ -replace "function disconnectedCleanup\(\)", "function disconnectedCleanup(%bool)"} | Set-Content $file.PSPath
  33.     (Get-Content $file.PSPath) | Foreach-Object{$_ -replace "parent::disconnectedCleanup\(\)", "parent::disconnectedCleanup(%bool)"} | Set-Content $file.PSPath
  34. }
  35.  
  36. #COMPRESS
  37. echo("3) Compressing files.`n")
  38. if(!(Test-Path ".\output"))
  39. {
  40.     mkdir ".\output"
  41. }
  42. Get-ChildItem ".\temp\" | `
  43. Foreach-Object{
  44.     $fullName = $_.FullName
  45.     $baseName = $_.BaseName
  46.     Write-Zip -Path "$fullName\*" -OutputPath ".\output\$baseName.zip"
  47. }
  48.  
  49. #MAKE REPO
  50. echo("4) Creating repository file.`n")
  51. .\make-repository.ps1
  52.  
  53. #CLEANUP
  54. echo("5. Removing temporary files.`n")
  55. Remove-Item ".\temp" -Recurse
Advertisement
Add Comment
Please, Sign In to add comment