Skip creating empty file (#333)
# Description Summary of changes: - Exit the function if the arrayList is empty. # Change type - [x] Bug fix (non-breaking change) - [ ] Code style update (formatting, local variables) - [ ] New Feature (non-breaking change that adds new functionality without impacting existing) - [ ] Breaking change (fix or feature that may cause functionality impact) - [ ] Other # Checklist: - [x] My code follows the style and contribution guidelines of this project. - [x] I have tested and validated my code changes.
This commit is contained in:
Родитель
86fe93bba0
Коммит
07b9dd929e
|
@ -43,9 +43,7 @@ function Export-ObjectToFile {
|
|||
|
||||
# create the parent directory structure if does not already exist
|
||||
if(!(Test-Path -Path $fileName.Directory -PathType Container)){
|
||||
|
||||
try {
|
||||
"Creating directory {0}" -f $fileName.Directory | Trace-Output -Level:Verbose
|
||||
$null = New-Item -Path $fileName.Directory -ItemType Directory -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
|
@ -55,14 +53,13 @@ function Export-ObjectToFile {
|
|||
}
|
||||
}
|
||||
process {
|
||||
# if object is null, then exit
|
||||
if ($null -eq $Object) {
|
||||
return
|
||||
}
|
||||
|
||||
$arrayList.AddRange($Object)
|
||||
}
|
||||
end {
|
||||
if ($arrayList.Count -eq 0) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
"Creating file {0}" -f $fileName | Trace-Output -Level:Verbose
|
||||
switch($FileType){
|
||||
|
|
Загрузка…
Ссылка в новой задаче