Skip to content

Commit 852680f

Browse files
authored
Add clean.cmd, clean.ps1 and clean.sh (dotnet#11154)
- dotnet#10463
1 parent 7932622 commit 852680f

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

clean.cmd

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@ECHO OFF
2+
SETLOCAL
3+
PowerShell -NoProfile -NoLogo -ExecutionPolicy ByPass -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; try { & '%~dp0clean.ps1' %*; exit $LASTEXITCODE } catch { write-host $_; exit 1 }"

clean.ps1

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#requires -version 5
2+
3+
<#
4+
.SYNOPSIS
5+
Clean this repository.
6+
7+
.DESCRIPTION
8+
This script cleans this repository interactively, leaving downloaded infrastructure untouched.
9+
Clean operation is interactive to avoid losing new but unstaged files. Press 'c' then [Enter]
10+
to perform the proposed deletions.
11+
12+
.EXAMPLE
13+
Perform default clean operation.
14+
15+
clean.ps1
16+
17+
.EXAMPLE
18+
Clean everything but downloaded infrastructure and VS / VS Code folders.
19+
20+
clean.ps1 -e .vs/ -e .vscode/
21+
#>
22+
23+
[CmdletBinding(PositionalBinding = $false)]
24+
param(
25+
# Other lifecycle targets
26+
[switch]$Help, # Show help
27+
28+
# Capture the rest
29+
[Parameter(ValueFromRemainingArguments = $true)]
30+
[string[]]$GitArguments
31+
)
32+
33+
Set-StrictMode -Version 2
34+
$ErrorActionPreference = 'Stop'
35+
36+
if ($Help) {
37+
Get-Help $PSCommandPath
38+
exit 0
39+
}
40+
41+
git clean -dix -e .dotnet/ -e .tools/ -e src/SignalR/clients/ts/FunctionalTests/node_modules/ @GitArguments

clean.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
#
6+
# Functions
7+
#
8+
__usage() {
9+
echo "Usage: $(basename "${BASH_SOURCE[0]}") <Arguments>
10+
11+
Arguments:
12+
<Arguments>... Arguments passed to the 'git' command. Any number of arguments allowed.
13+
14+
Description:
15+
This script cleans the repository interactively, leaving downloaded infrastructure untouched.
16+
Clean operation is interactive to avoid losing new but unstaged files. Press 'c' then [Enter]
17+
to perform the proposed deletions.
18+
"
19+
}
20+
21+
git_args=()
22+
23+
while [[ $# -gt 0 ]]; do
24+
case $1 in
25+
-\?|-h|--help)
26+
__usage
27+
exit 0
28+
;;
29+
*)
30+
git_args[${#git_args[*]}]="$1"
31+
;;
32+
esac
33+
shift
34+
done
35+
36+
# This incantation avoids unbound variable issues if git_args is empty
37+
# https://stackoverflow.com/questions/7577052/bash-empty-array-expansion-with-set-u
38+
git clean -dix -e .dotnet/ -e .tools/ ${git_args[@]+"${git_args[@]}"}

0 commit comments

Comments
 (0)