From a83c01b58aab72f5ec372556577fd0012c8aca8b Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Mon, 30 Jun 2025 13:00:25 +0200 Subject: [PATCH] Updated clean-repo.ps1 and kill-process.ps1 --- scripts/clean-repo.ps1 | 5 ++++- scripts/kill-process.ps1 | 33 ++++++++++++--------------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/scripts/clean-repo.ps1 b/scripts/clean-repo.ps1 index cab26655..d8044902 100755 --- a/scripts/clean-repo.ps1 +++ b/scripts/clean-repo.ps1 @@ -22,6 +22,8 @@ param([string]$path = "$PWD") try { + $stopWatch = [system.diagnostics.stopwatch]::startNew() + Write-Host "⏳ (1/4) Searching for Git executable... " -noNewline & git --version if ($lastExitCode -ne 0) { throw "Can't execute 'git' - make sure Git is installed and available" } @@ -42,7 +44,8 @@ try { & git -C "$path" submodule foreach --recursive git clean -xfd -f # to delete all untracked files in the submodules if ($lastExitCode -ne 0) { throw "'git clean' in the submodules failed with exit code $lastExitCode" } - "✅ Repo '$repoName' is clean now." + [int]$elapsed = $stopWatch.Elapsed.TotalSeconds + "✅ Repo '$repoName' cleaned in $($elapsed)s." exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/scripts/kill-process.ps1 b/scripts/kill-process.ps1 index a44334e5..e4ddc2bf 100755 --- a/scripts/kill-process.ps1 +++ b/scripts/kill-process.ps1 @@ -1,35 +1,26 @@ <# .SYNOPSIS - Kills all local processes matching the given name + Kills local processes .DESCRIPTION - ← enter a detailed description of the script here -.PARAMETER - ← enter the description of a parameter here (repeat the .PARAMETER for each parameter) + This PowerShell script stops all local processes matching the given name +.PARAMETER processName + Specifies the process name (ask user by default) .EXAMPLE - ← enter a sample command that uses the script, optionally followed by sample output and a description (repeat the .EXAMPLE for each example) -.NOTES - Author: ← enter full name here - License: ← enter license here + PS> ./kill-process.ps1 .LINK - ← enter URL to additional information here + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 #> -[CmdletBinding()] -param( -# [Parameter(Mandatory,ParameterSetName='ByProcessName')] - [string]$ProcessName = $(Read-Host -Prompt 'Enter the process name')) - -function KillProcesses { - Write-Host -BackgroundColor Yellow -ForegroundColor Red "Process to kill: $ProcessName" - Get-Process | Where-Object -FilterScript {$_.processname -eq $ProcessName} | Select-Object id | Stop-Process -} - +param([string]$processName = "") try { - KillProcesses -ProcessName $processName + if ($processName -eq "") { $processName = Read-Host "Enter the process name" } + Get-Process | Where-Object -FilterScript {$_.processname -eq $processName} | Select-Object id | Stop-Process "✔️ Done." exit 0 # success } catch { - "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + "⚠️ ERROR: $($Error[0])" exit 1 }