little_strategy/script_pubget.ps1

33 lines
1.1 KiB
PowerShell
Raw Permalink Normal View History

2024-11-18 06:44:55 +00:00
# Define a function that recursively searches for Flutter projects and runs `flutter clean`
function Clean-FlutterProjects {
param (
[string]$StartPath
)
# Check if the starting directory contains a pubspec.yaml file (indicating a Flutter project)
if (Test-Path "$StartPath\pubspec.yaml") {
Write-Host "Cleaning Flutter project in: $StartPath"
Push-Location $StartPath
flutter pub get
Pop-Location
}
# Get all directories recursively from the start path
$directories = Get-ChildItem -Path $StartPath -Recurse -Directory
foreach ($directory in $directories) {
# Check if the directory contains a pubspec.yaml file (indicating a Flutter project)
if (Test-Path "$($directory.FullName)\pubspec.yaml") {
Write-Host "Cleaning Flutter project in: $($directory.FullName)"
# Navigate to the directory and run `flutter clean`
Push-Location $directory.FullName
flutter pub get
Pop-Location
}
}
}
# Run the function starting from the current directory
Clean-FlutterProjects -StartPath (Get-Location)