Made Powershell Strict Complient
This commit is contained in:
parent
205115ea1f
commit
f8e1600444
1 changed files with 12 additions and 10 deletions
|
@ -26,14 +26,14 @@ $result = New-Object psobject @{
|
||||||
changed = $false
|
changed = $false
|
||||||
}
|
}
|
||||||
|
|
||||||
If ($params.creates) {
|
If (Get-Member -InputObject $params -Name creates) {
|
||||||
If (Test-Path $params.creates) {
|
If (Test-Path $params.creates) {
|
||||||
Exit-Json $result "The 'creates' file or directory already exists."
|
Exit-Json $result "The 'creates' file or directory already exists."
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
If ($params.src) {
|
If (Get-Member -InputObject $params -Name src) {
|
||||||
$src = $params.src.toString()
|
$src = $params.src.toString()
|
||||||
|
|
||||||
If (-Not (Test-Path -path $src)){
|
If (-Not (Test-Path -path $src)){
|
||||||
|
@ -62,24 +62,26 @@ Else {
|
||||||
Fail-Json $result "missing required argument: dest"
|
Fail-Json $result "missing required argument: dest"
|
||||||
}
|
}
|
||||||
|
|
||||||
If ($params.recurse) {
|
If (Get-Member -InputObject $params -Name recurse) {
|
||||||
$recurse = ConvertTo-Bool ($params.recurse)
|
$recurse = ConvertTo-Bool ($params.recurse)
|
||||||
}
|
}
|
||||||
Else {
|
Else {
|
||||||
$recurse = $false
|
$recurse = $false
|
||||||
}
|
}
|
||||||
|
|
||||||
If ($params.rm) {
|
If (Get-Member -InputObject $params -Name rm) {
|
||||||
$rm = ConvertTo-Bool ($params.rm)
|
$rm = ConvertTo-Bool ($params.rm)
|
||||||
}
|
}
|
||||||
Else {
|
Else {
|
||||||
$rm = $false
|
$rm = $false
|
||||||
}
|
}
|
||||||
|
|
||||||
If ($ext -eq ".zip" -And $recurse -eq $false) {
|
If ($ext -eq ".zip" -And $recurse -eq $false) {
|
||||||
Try {
|
Try {
|
||||||
$shell = New-Object -ComObject Shell.Application
|
$shell = New-Object -ComObject Shell.Application
|
||||||
$shell.NameSpace($dest).copyhere(($shell.NameSpace($src)).items(), 20)
|
$zipPkg = $shell.NameSpace($src)
|
||||||
|
$destPath = $shell.NameSpace($dest)
|
||||||
|
$destPath.CopyHere($zipPkg.Items())
|
||||||
$result.changed = $true
|
$result.changed = $true
|
||||||
}
|
}
|
||||||
Catch {
|
Catch {
|
||||||
|
@ -154,4 +156,4 @@ Set-Attr $result.win_unzip "src" $src.toString()
|
||||||
Set-Attr $result.win_unzip "dest" $dest.toString()
|
Set-Attr $result.win_unzip "dest" $dest.toString()
|
||||||
Set-Attr $result.win_unzip "recurse" $recurse.toString()
|
Set-Attr $result.win_unzip "recurse" $recurse.toString()
|
||||||
|
|
||||||
Exit-Json $result;
|
Exit-Json $result;
|
||||||
|
|
Loading…
Reference in a new issue