@@ -46,75 +46,75 @@ function Invoke-Fasti {
4646
4747 # process each archive file found in current directory
4848 Get-ChildItem $extensions - File - ErrorAction SilentlyContinue |
49- ForEach-Object {
49+ ForEach-Object {
5050
51- Write-Verbose " Processing archive: $ ( $PSItem.Name ) "
51+ Write-Verbose " Processing archive: $ ( $PSItem.Name ) "
5252
53- # initialize 7zip executable path
54- $sevenZip = " 7z"
53+ # initialize 7zip executable path
54+ $sevenZip = " 7z"
5555
56- # get archive details
57- $zipFile = $PSItem.fullname
58- $name = [system.IO.Path ]::GetFileNameWithoutExtension($zipFile )
59- $path = [System.IO.Path ]::GetDirectoryName($zipFile )
60- $extractPath = [system.Io.Path ]::Combine($path , $name )
56+ # get archive details
57+ $zipFile = $PSItem.fullname
58+ $name = [system.IO.Path ]::GetFileNameWithoutExtension($zipFile )
59+ $path = [System.IO.Path ]::GetDirectoryName($zipFile )
60+ $extractPath = [system.Io.Path ]::Combine($path , $name )
6161
62- # create extraction directory if it doesn't exist
63- if ([System.IO.Directory ]::exists($extractPath ) -eq $false ) {
62+ # create extraction directory if it doesn't exist
63+ if ([System.IO.Directory ]::exists($extractPath ) -eq $false ) {
6464
65- Write-Verbose " Creating directory: $extractPath "
66- [System.IO.Directory ]::CreateDirectory($extractPath )
67- }
65+ Write-Verbose " Creating directory: $extractPath "
66+ [System.IO.Directory ]::CreateDirectory($extractPath )
67+ }
6868
69- # verify 7zip installation or attempt to install it
70- if ((Get-Command $sevenZip - ErrorAction SilentlyContinue).Length -eq 0 ) {
69+ # verify 7zip installation or attempt to install it
70+ if ((Get-Command $sevenZip - ErrorAction SilentlyContinue).Length -eq 0 ) {
7171
72- $sevenZip = " ${env: ProgramFiles} \7-Zip\7z.exe"
72+ $sevenZip = " ${env: ProgramFiles} \7-Zip\7z.exe"
7373
74- if (! [IO.File ]::Exists($sevenZip )) {
74+ if (! [IO.File ]::Exists($sevenZip )) {
7575
76- if ((Get-Command winget - ErrorAction SilentlyContinue).Length -eq 0 ) {
76+ if ((Get-Command winget - ErrorAction SilentlyContinue).Length -eq 0 ) {
7777
78- throw " You need to install 7zip or winget first"
79- }
78+ throw " You need to install 7zip or winget first"
79+ }
8080
81- Write-Verbose " Installing 7-Zip via winget..."
82- winget install 7zip
81+ Write-Verbose " Installing 7-Zip via winget..."
82+ winget install 7zip
8383
84- if (! [IO.File ]::Exists($sevenZip )) {
84+ if (! [IO.File ]::Exists($sevenZip )) {
8585
86- throw " You need to install 7-zip"
87- }
86+ throw " You need to install 7-zip"
8887 }
8988 }
89+ }
9090
91- # extract archive contents
92- Write-Verbose " Extracting to: $extractPath "
93- $pwparam = if ($Password ) { " -p$Password " } else { " " }
94- if ([string ]::IsNullOrWhiteSpace($Password )) {
91+ # extract archive contents
92+ Write-Verbose " Extracting to: $extractPath "
93+ $pwparam = if ($Password ) { " -p$Password " } else { " " }
94+ if ([string ]::IsNullOrWhiteSpace($Password )) {
9595
96- & $sevenZip x - y " -o$extractPath " $zipFile
97- }
98- else {
96+ & $sevenZip x - y " -o$extractPath " $zipFile
97+ }
98+ else {
9999
100- & $sevenZip x - y $pwparam " -o$extractPath " $zipFile
101- }
100+ & $sevenZip x - y $pwparam " -o$extractPath " $zipFile
101+ }
102102
103- # delete original archive if extraction succeeded
104- if ($? ) {
103+ # delete original archive if extraction succeeded
104+ if ($? ) {
105105
106- try {
107- Write-Verbose " Removing original archive: $zipFile "
108- Remove-Item " $zipFile " - Force - ErrorAction silentlycontinue
109- }
110- catch {
111- Write-Verbose " Failed to remove original archive"
112- }
106+ try {
107+ Write-Verbose " Removing original archive: $zipFile "
108+ Remove-Item " $zipFile " - Force - ErrorAction silentlycontinue
109+ }
110+ catch {
111+ Write-Verbose " Failed to remove original archive"
113112 }
114113 }
114+ }
115115 }
116116
117117 end {
118118 }
119119}
120- # ###############################################################################
120+ # ###############################################################################
0 commit comments