Skip to content

Instantly share code, notes, and snippets.

@humazed
Last active July 2, 2024 06:12
Show Gist options
  • Select an option

  • Save humazed/0d0c5fc7b0bf7c87adfa2cf5f75b2e30 to your computer and use it in GitHub Desktop.

Select an option

Save humazed/0d0c5fc7b0bf7c87adfa2cf5f75b2e30 to your computer and use it in GitHub Desktop.

Revisions

  1. humazed revised this gist Aug 24, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cleanup_all_projects.ps1
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ Get-ChildItem -Path $rootPath -Recurse -Directory | ForEach-Object {
    Get-ChildItem -Path $currentDir.FullName -Recurse -Include *.apk, *.aab, *.a, *.log, *.tmp, *.bak, *.swp, .DS_Store | Remove-Item -Force

    # Delete unnecessary folders
    $foldersToRemove = @("build", "node_modules", "temp", ".gradle", ".idea", "obj")
    $foldersToRemove = @("build", "node_modules", "temp")
    $foldersToRemove | ForEach-Object {
    $folderPath = Join-Path -Path $currentDir.FullName -ChildPath $_
    if (Test-Path $folderPath) {
  2. humazed created this gist Apr 29, 2023.
    36 changes: 36 additions & 0 deletions cleanup_all_projects.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    Write-Host "Cleaning up build files in all Flutter and Android projects..."

    $rootPath = Get-Location

    Get-ChildItem -Path $rootPath -Recurse -Directory | ForEach-Object {
    $currentDir = $_
    $flutterProject = Join-Path $currentDir.FullName "pubspec.yaml"
    $androidProject = Join-Path $currentDir.FullName "android\gradlew"

    if (Test-Path $flutterProject) {
    Write-Host "Cleaning Flutter project in $($currentDir.FullName)..."
    Set-Location $currentDir.FullName
    & flutter clean
    }

    if (Test-Path $androidProject) {
    Write-Host "Cleaning Android project in $($currentDir.FullName)..."
    Set-Location (Join-Path $currentDir.FullName "android")
    & .\gradlew clean
    Set-Location $rootPath
    }

    # Delete APK files, AAB files, other build files, and additional useless files
    Get-ChildItem -Path $currentDir.FullName -Recurse -Include *.apk, *.aab, *.a, *.log, *.tmp, *.bak, *.swp, .DS_Store | Remove-Item -Force

    # Delete unnecessary folders
    $foldersToRemove = @("build", "node_modules", "temp", ".gradle", ".idea", "obj")
    $foldersToRemove | ForEach-Object {
    $folderPath = Join-Path -Path $currentDir.FullName -ChildPath $_
    if (Test-Path $folderPath) {
    Remove-Item -Recurse -Force $folderPath
    }
    }
    }

    Write-Host "All done! Build files and other useless files have been cleaned up in all projects."