-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathclean-typescript-ccs-files.ps1
More file actions
35 lines (31 loc) · 1.33 KB
/
clean-typescript-ccs-files.ps1
File metadata and controls
35 lines (31 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
param (
[Parameter(Mandatory = $true)]
[string]
$targetDirectory,
[Parameter(Mandatory = $true)]
[string]
$packageName
)
Push-Location $targetDirectory
Write-Host "Starting cleaning operation in target directory: $targetDirectory"
$kiotaLockFileName = "kiota-lock.json"
# Extract folder name from package name (the part after the slash)
$folderToClean = $packageName.Split("/")[1]
$folderToCleanPath = Join-Path $targetDirectory -ChildPath $folderToClean -AdditionalChildPath "generated"
# Check if the folder to clean exists
if (Test-Path $folderToCleanPath) {
Write-Host "Cleaning contents in: $folderToClean" -ForegroundColor Cyan
Push-Location $folderToCleanPath
# Clean directories
Get-ChildItem -Directory | ForEach-Object { Remove-Item -r $_.FullName }
# Clean TypeScript files except index.ts
Remove-Item *.ts -Exclude "index.ts"
# Remove kiota lock file
Remove-Item $kiotaLockFileName -ErrorAction SilentlyContinue -Verbose
Pop-Location
Write-Host "Successfully cleaned contents in: $folderToClean" -ForegroundColor Green
} else {
Write-Host "Warning: Folder '$folderToClean' does not exist in the target directory." -ForegroundColor Yellow
}
Pop-Location
Write-Host "Cleaning operation completed for target: $folderToClean derived from package: $packageName" -ForegroundColor Green