forked from router-for-me/EasyCLIProxyAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean.ps1
More file actions
39 lines (31 loc) · 1.05 KB
/
Copy pathclean.ps1
File metadata and controls
39 lines (31 loc) · 1.05 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
36
37
38
39
[CmdletBinding()]
param()
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$RootDir = [System.IO.Path]::GetFullPath($PSScriptRoot).TrimEnd(
[System.IO.Path]::DirectorySeparatorChar,
[System.IO.Path]::AltDirectorySeparatorChar
)
$RootPrefix = "$RootDir$([System.IO.Path]::DirectorySeparatorChar)"
$BinDir = Join-Path $RootDir 'bin-work'
Set-Location -LiteralPath $RootDir
$CleanTargets = @(
(Join-Path $RootDir 'dist'),
(Join-Path $RootDir 'src-tauri\target'),
(Join-Path $RootDir 'src-tauri\gen'),
$BinDir
)
foreach ($Target in $CleanTargets) {
$ResolvedTarget = [System.IO.Path]::GetFullPath($Target)
if (-not $ResolvedTarget.StartsWith(
$RootPrefix,
[System.StringComparison]::OrdinalIgnoreCase
)) {
throw "Refusing to clean a path outside the project: $ResolvedTarget"
}
if (Test-Path -LiteralPath $ResolvedTarget) {
Remove-Item -LiteralPath $ResolvedTarget -Recurse -Force
}
}
New-Item -ItemType Directory -Path $BinDir -Force | Out-Null
Write-Host 'Cleaned build output.'