PSMinifier icon indicating copy to clipboard operation
PSMinifier copied to clipboard

A Miniature Minifier For PowerShell

Results 10 PSMinifier issues
Sort by recently updated
recently updated
newest added

``` function testfunc($str1, $str2) { 'calling testfunc' $str1 $str2 } function testfunc2 { Param([string]$str1, [string]$str2) 'calling testfunc2' $str1 $str2 } testfunc 'foo' 'bar' testfunc2 'foo' 'bar' ``` Output: ``` calling...

PSMinifier should make itself available as a microservice, so that scripts can be minified without the direct installation of PSMinifier.

This approach yields excess warnings in some environments.

Parameter default values are stripped. ```powershell $ScriptContent = @" Function Write-TestHost { Param( `$Message = "Test" ) Write-Host "Message: `$Message" } Write-TestHost "@ $ScriptBlock = [ScriptBlock]::Create($ScriptContent) Compress-ScriptBlock -ScriptBlock $ScriptBlock -OutputPath...

Pragmas such as `#requires` are stripped, might relate to #17 ```powershell $ScriptContent = @" #requires -Version 5.1 -RunAsAdministrator Write-Host "Hello World" "@ $ScriptBlock = [ScriptBlock]::Create($ScriptContent) Compress-ScriptBlock -ScriptBlock $ScriptBlock -OutputPath ".\Test-PragmaScript.ps1"...

Switch Cases aren't minified, see example. ```powershell $ScriptContent = @" Write-Host "Start" if(`$true) { Write-Host "True is True" } else { Write-Host "True is False?" } switch(3) { 1 {...

~~~PowerShell Compress-ScriptBlock -ScriptBlock { $c, $t, $id = 0, $allFiles.Count, $(Get-Random) } # Fails (but should not) Compress-ScriptBlock -ScriptBlock { $c, $t, $id = 0, $allFiles.Count, [Random]::new().Next() } # works...

bug

In this PR I have implemented variable renaming and command shortening via aliases.

PSMinifier should be able to run in such a way that it keeps inline help.

enhancement

Class structure remains unchanged.