diff --git a/deploy.ps1 b/deploy.ps1 index 5644884..bb9e2cb 100644 --- a/deploy.ps1 +++ b/deploy.ps1 @@ -40,15 +40,17 @@ Write-Host "Beginning deployment" -ForegroundColor Green $ModuleName = 'NetboxPS' $ConcatenatedFilePath = "$PSScriptRoot\concatenated.ps1" -$PSD1OutputPath = "$PSScriptRoot\$ModuleName\$ModuleName.psd1" -$PSM1OutputPath = "$PSScriptRoot\$ModuleName\$ModuleName.psm1" +$FunctionPath = "$PSScriptRoot\Functions" +$OutputDirectory = "$PSScriptRoot\$ModuleName" +$PSD1OutputPath = "$OutputDirectory\$ModuleName.psd1" +$PSM1OutputPath = "$OutputDirectory\$ModuleName.psm1" -$PS1Files = Get-ChildItem "$PSScriptRoot\Functions" -Filter "*.ps1" -Recurse | Sort-Object Name +$PS1Files = Get-ChildItem $FunctionPath -Filter "*.ps1" -Recurse | Sort-Object Name "" | Out-File -FilePath $ConcatenatedFilePath -Encoding utf8 $Counter = 0 -Write-Host "Concatenating [$($PS1Files.Count)] PS1 files from $PSScriptRoot\Functions" +Write-Host "Concatenating [$($PS1Files.Count)] PS1 files from $FunctionPath" foreach ($File in $PS1Files) { $Counter++ @@ -109,6 +111,16 @@ switch ($PSCmdlet.ParameterSetName) { } } + +if (-not (Test-Path $OutputDirectory)) { + try { + Write-Warning "Creating path [$OutputDirectory]" + $null = New-Item -Path $OutputDirectory -ItemType Directory -Force + } catch { + throw "Failed to create directory [$OutputDirectory]: $($_.Exception.Message)" + } +} + Write-Host " Copying psd1" Copy-Item -Path "$PSScriptRoot\$ModuleName.psd1" -Destination $PSD1OutputPath -Force