-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pack-docs.ps1
39 lines (37 loc) · 1.22 KB
/
pack-docs.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
param
(
[parameter(Mandatory = $true)]
[string] $DocsPath,
[parameter(Mandatory = $true)]
[string] $OutputPath,
[parameter(Mandatory = $true)]
[string] $PackageName
)
# Backup the environment
$current_location = Get-Location
function PackDocs([string] $target_dir_path, [string] $output_dir_path, [string] $pack_name)
{
# Form target path
$target_path = Get-Item "$target_dir_path"
$target_path = $target_path.FullName
$target_path = Join-Path "$target_path" "_site"
# Form output path
$output_path_dir = Get-Item "$output_dir_path"
$output_path_dir = $output_path_dir.FullName
$output_path = Join-Path "$output_path_dir" "$pack_name"
# Enter target path
Set-Location -path "$target_path"
# Check if target .zip exists
# If it does, remove it
if (Test-Path "$output_path.zip")
{
Write-Host "$output_path.zip exists, deleting"
Remove-Item "$output_path.zip"
}
# Package .zip archive
Write-Host "Packing $output_path.zip"
Compress-Archive -Path "$target_path/*" -DestinationPath "$output_path.zip" -Force -CompressionLevel Fastest
# Exit back
Set-Location -path "$current_location"
}
PackDocs "$DocsPath" "$OutputPath" "$PackageName"