WinPath-Clean.psm1
|
#Requires -Version 7.0 #Requires -PSEdition Core <# .SYNOPSIS WinPath-Clean - A PowerShell 7 TUI tool to analyze, clean, and optimize Windows PATH. .DESCRIPTION This module provides functions to analyze the Windows PATH environment variable, detect duplicates and obsolete entries, and safely apply a cleaned version. .NOTES Author: Ignacio de Miguel Diaz Version: 0.1.0 License: MIT #> # Import private functions $Private = @(Get-ChildItem -Path "$PSScriptRoot\Private\*.ps1" -ErrorAction SilentlyContinue) foreach ($file in $Private) { try { . $file.FullName } catch { Write-Error "Failed to import private function $($file.FullName): $_" } } # Import public functions $Public = @(Get-ChildItem -Path "$PSScriptRoot\Public\*.ps1" -ErrorAction SilentlyContinue) foreach ($file in $Public) { try { . $file.FullName } catch { Write-Error "Failed to import public function $($file.FullName): $_" } } # Module-level variables $script:ModuleVersion = '0.1.0' $script:ConfigPath = Join-Path $env:USERPROFILE '.config\winpath-clean' $script:BackupPath = Join-Path $script:ConfigPath 'backups' # Ensure config directory exists if (-not (Test-Path $script:ConfigPath)) { New-Item -ItemType Directory -Path $script:ConfigPath -Force | Out-Null } if (-not (Test-Path $script:BackupPath)) { New-Item -ItemType Directory -Path $script:BackupPath -Force | Out-Null } # Set aliases Set-Alias -Name 'wpc' -Value 'Invoke-WinPathClean' Set-Alias -Name 'pathclean' -Value 'Invoke-WinPathClean' # Export module members Export-ModuleMember -Function $Public.BaseName -Alias @('wpc', 'pathclean') |