Skip to content

Commit

Permalink
fix: Initialize-Splatter will no longer -Minify or -Compress ( Fixes #28
Browse files Browse the repository at this point in the history
 )
  • Loading branch information
James Brundage committed Sep 1, 2024
1 parent ab91940 commit 7c57c73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 77 deletions.
78 changes: 7 additions & 71 deletions Initialize-Splatter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
.Link
Merge-Splat
.Example
Initialize-Splatter > '@.ps1' # Initialize Splatter
.Example
Initialize-Splatter -Compress > '@.ps1'
Initialize-Splatter > '@.ps1' # Initialize Splatter
.Example
Initialize-Splatter -Verb Get > '@.ps1' # Initialize splatter
#>
[Alias('Include-Splatter','Inline-Splatter')]
param(
# The verbs to install.
[Parameter(ValueFromPipelineByPropertyName=$true)]
Expand All @@ -31,13 +30,7 @@
[Parameter(ValueFromPipelineByPropertyName=$true)]
[Alias('NoCompression')]
[switch]
$Compress,

# If set, will not minify the definitions
[Parameter(ValueFromPipelineByPropertyName=$true)]
[Alias('NoMinification')]
[switch]
$Minify,
$Compress,

# If set, will not add a line of documentation linking to the module
[Parameter(ValueFromPipelineByPropertyName=$true)]
Expand Down Expand Up @@ -67,41 +60,6 @@
)

begin {
$CompressScriptBlock = ([ScriptBlock]::Create((
[IO.StreamReader]::new(([IO.Compression.GZipStream]::new(
[IO.MemoryStream]::new([Convert]::FromBase64String(@'
H4sIAAAAAAAEAM1ZW08jNxT2T4mqaENUGLV97AiJZQvVSr2gsmofEKoyYRbSJpBmhnZpNv+93znH
Httje5IszKqKJmR8rj53m6WaqBWehTpQV+qieStVjWeF1R/xfq9u8F2rB6w8qWM1xO+VegTGWF2D
7lJN8T5TS6yfqjnwpupPQIYJyFgVoL3F+r1aq/fMt4SEqbqDxKH6XQ0YNlAjUNGvCUs+Ux/AiXAr
fGaguwfGIZ40JK5BGl9sUOI9jfMaq2SnLo0uYZ+iA/4Gvxf4iHVja2nat7DZJfYzYS8tWNtaw34A
3gPoUvDXm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6bdr9qp0zlMlcE8GqXmsW3NfY1dT6nrCf8JZ9i9X2dyJ8rQmucen9jrl/pr+AxvO
2FpGW7tysFWX/WTdYDWUR6ummrUz8xSwG3DpLxu3R2Fc6/2tFGZ9Oud3u/+U/J84+S+Wm+iMk7Nv
fELI+CZ0xh1/zPpPdC1MnY+JQu42rc2Epn1W7q/z2/sgkbxqJD/v/m4f36TvqKrPfItndUrdahvd
Ruz9p478qnrLr9hkFM5GxI/g4ZQ00mcD6QE29qY8bVhKk7dCFZNaO1K7qa0Mittz6DPHx/ZLscCK
rfQb58id7ppPbEmyTMaZLzu40jUizY9uDyovR0NuktMEJXljtvF1MCV2y7I0m0jNFav0HxVhxvkz
3LmSu0XS/Knpou7aWu8yTtGn5l15uNu53p9W4zhpaGoX3Wd/wzF1WtwVL3WqTJ992+dLqd1kY7eL
1E7c2b5Wc2drw0WHQvc9CzX/rbUaxOeGnE/OPvWFd5rchUPZ4nCmb4S2UbpTs5Vu7OPfOJCeRUvP
EDNWYyfeHUjB3bfW/iy4D5taR7hSCVwvmZoQcl4GnMP7gq5byUnrdmabXoJl6lfYqcO7STtz2apS
NN3E/a++rXzFi9UHK3PZyGzfVVi5yx7ktrtYwRWK/ODqVHK8rjXtSUP5PG26ZZoKGjsBt230abds
cXimMTbqP/VR4etMIgAA
'@ )),
[IO.Compression.CompressionMode]'Decompress')),([Text.Encoding]::unicode))).ReadToEnd()
))

$myModule = $MyInvocation.MyCommand.ScriptBlock.Module
}

Expand Down Expand Up @@ -149,11 +107,7 @@ cXimMTbqP/VR4etMIgAA
"`${function:$v-Splat}"
}

if ($Minify) {
Write-Progress "Minifying" $v -PercentComplete $p -id $id
if ($val -isnot [ScriptBlock]) { $val = [ScriptBlock]::Create($val) }
"{$(& $CompressScriptBlock $val)}"
} elseif ($NoHelp) {
if ($NoHelp) {
"{$($val -replace '\<\#(?<Block>(.|\s)+?(?=\#>))\#\>', '')}"
} else {
"{$val}"
Expand All @@ -168,30 +122,12 @@ cXimMTbqP/VR4etMIgAA
}
}
}

if ($Compress) {
Write-Progress "Compressing" " " -PercentComplete 99 -id $id
$data = [Text.Encoding]::Unicode.GetBytes("$($innerContent -join [Environment]::NewLine)")
$ms = New-Object IO.MemoryStream
$cs = New-Object System.IO.Compression.GZipStream ($ms, [Io.Compression.CompressionMode]"Compress")
$cs.Write($Data, 0, $Data.Length)
$cs.Close()
$cs.Dispose()
".([ScriptBlock]::Create(([IO.StreamReader]::new((
[IO.Compression.GZipStream]::new([IO.MemoryStream]::new(
[Convert]::FromBase64String('
$([Convert]::ToBase64String($ms.ToArray(), 'InsertLineBreaks'))
')),
[IO.Compression.CompressionMode]'Decompress')),
[Text.Encoding]::unicode)).ReadToEnd()
))"
} else {

@(@(if (-not $inline) {'

@(@(if (-not $inline) {'
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Justification="This Declares Variables for Other Scripts")]
param()'
}) + $innerContent) -join [Environment]::NewLine
}

if (-not $NoLogo) {
"#endregion $logo"
}) -join [Environment]::NewLine
Expand Down
7 changes: 1 addition & 6 deletions Splatter.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,7 @@ describe Splatter {
it 'is pretty small' {
$embeddedSplatter = Initialize-Splatter
$embeddedSplatter.Length | should -Belessthan 30kb
}

it 'can -Be minified and compressed' {
$embeddedSplatter = Initialize-Splatter -Minify -Compress
$embeddedSplatter.Length | should -Belessthan 10kb
}
}

it 'Can -Be embedded as a functionl' {
$embeddedSplatter = Initialize-Splatter -Verb Get
Expand Down

0 comments on commit 7c57c73

Please sign in to comment.