Skip to content

Commit

Permalink
Merge pull request #16 from stadub/7-Zip-Release-1.1
Browse files Browse the repository at this point in the history
7 zip release 1.1  Fix issues #14 #15
  • Loading branch information
stadub committed Sep 9, 2019
2 parents e3ff052 + 6f8e8f6 commit 3ecfd23
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 241 deletions.
9 changes: 9 additions & 0 deletions 7Zip/7zip-Archive.SmokeTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Import-Module .\7zip-Archive.psm1


ls -Exclude .git | New-ZipFile "scripts"
Test-ZipFileContent .\scripts.7z
Get-ZipFileContent -Archive .\scripts.7z
Remove-ZipFileContent -Archive .\scripts.7z -File "temp.log"
Read-ZipFile -Archive .\scripts.7z
Add-ZipFileContent -Path .\scripts.7z -FileName .\7zip-Archive.psd1
3 changes: 2 additions & 1 deletion 7Zip/7zip-Archive.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
# RootModule = ''

# Version number of this module.
ModuleVersion = '1.0.3'

ModuleVersion = '1.1.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
2 changes: 1 addition & 1 deletion 7Zip/7zip-Archive.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

. $PSScriptRoot\Functions.ps1

CheckPsGalleryUpdate "7zip-Archive" "1.0.3"
szCheckPsGalleryUpdate 7Zip "1.1.0"

_Initalize

Expand Down
1 change: 1 addition & 0 deletions 7Zip/Aliases.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Set-Alias sza Add-ZipFileContent -Scope Global
Set-Alias szrm Remove-ZipFileContent -Scope Global
Set-Alias szt Test-ZipFileContent -Scope Global
Set-Alias br Get-ZipFileContent -Scope Global
Set-Alias szc New-ZipFile -Scope Global

25 changes: 12 additions & 13 deletions 7Zip/Functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function _Initalize() {

$script:_binDir = Get-ProfileDir "7zip" "bin"
$script:_binDir = szGet-ProfileDir "7zip" "bin"
Write-Debug "The 7-zip is dir set to $_binDir"
$script:_7zWin = Join-Path $_binDir "7za.exe"
$script:_7zWinDownloadDir='https://www.7-zip.org/a/7za920.zip'
Expand All @@ -22,19 +22,19 @@ function Test-7ZipInstall {
Write-Debug "Trying to locate 7-zip by the path: $script:_7zWin"

if( -not (Test-Path "$script:_7zWin")){
Write-Output '7Zip didn''t found.'
Write-Output '7Zip didn''t downloaded.'
Write-Output 'Now script going to try to download it.'

$file = Get-TempFileName
$file = szGet-TempFileName
Write-Debug "Temp file: ${file}"

Receive-File "7-Zip" $file $_7zWinDownloadDir
szReceive-File "7-Zip" $file $_7zWinDownloadDir
Write-Debug "Extracting to directory ${_binDir}"
if ( -not (Test-Path $_binDir )) {
New-Item -Path $_binDir -ItemType 'Directory'
}

Extract-ZipFile -FileName "$file" -Path "$_binDir"
szExtract-ZipFile -FileName "$file" -Path "$_binDir"
}
$script:_7zPath = $script:_7zWin

Expand All @@ -56,7 +56,7 @@ function AddKeyArg {
$AllArgs = $null,
[string]$Key = $null
)
if( -not (Test-Empty $Key)){
if( -not (szTest-Empty $Key)){
$AllArgs += "-p$Key"
}
return $AllArgs
Expand Down Expand Up @@ -206,7 +206,6 @@ function Remove-ZipFileContent {
[Alias("Path","Name", "Archive", "p")]
[string]$ArchiveName,

[ValidateScript( { Test-Path $_ -pathType leaf })]
[Parameter(Position = 1, Mandatory = $true)]
[Alias("File", "f")]
[string]$FileName,
Expand Down Expand Up @@ -364,7 +363,7 @@ function New-ZipFile {
process {

$FileNames| ForEach-Object{
if( -not (Test-Empty $_) ){
if( -not (szTest-Empty $_) ){
Write-Debug "Adding file ""$_"""
$files += $_
}
Expand Down Expand Up @@ -432,7 +431,7 @@ function New-ZipFile {
}


if( -not (Test-Empty $([string]$SplitSize) )){
if( -not (szTest-Empty $([string]$SplitSize) )){

$factorName="b"
switch ( $SplitSizeFactor )
Expand Down Expand Up @@ -518,7 +517,7 @@ function Test-ZipFileContent {
$AllArgs = @('t', "$ArchiveName")


if( -not (Test-Empty $FileName) ){
if( -not (szTest-Empty $FileName) ){
$AllArgs += "$FileName"
}

Expand Down Expand Up @@ -586,12 +585,12 @@ function Get-ZipFileContent {

$AllArgs = @('e', "$ArchiveName")

if( -not (Test-Empty $FileName) ){
if( -not (szTest-Empty $FileName) ){
$AllArgs += "$FileName"
}

if( -not (Test-Empty $destFolder) ){
CreateFolderIfNotExist "${destFolder}"
if( -not (szTest-Empty $destFolder) ){
szCreateFolderIfNotExist "${destFolder}"
$AllArgs += "-o$destFolder"
}

Expand Down
8 changes: 8 additions & 0 deletions 7Zip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Test-ZipFileContent - Perform zip file check

| Cmdlet | Alias |
| ---------------------|:------:|
| New-ZipFile | szc |
| Read-ZipFile | szr |
| Add-ZipFileContent | sza |
| Remove-ZipFileContent| szrm |
Expand Down Expand Up @@ -179,6 +180,13 @@ Test-ZipFileContent - Perform zip file check

## Changelog


### [v1.1.0](https://github.com/stadub/PowershellScripts/releases/tag/v0.9.5) Spet 9, 2019

* Fix Remove-ZipFileContent error #15
* Fix szc Allias #14
* Add smoke tests

### [v1.0.0](https://github.com/stadub/PowershellScripts/releases/tag/v0.4.0)

*First public release.
Expand Down
Loading

0 comments on commit 3ecfd23

Please sign in to comment.