-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.compressor.ps1
50 lines (37 loc) · 985 Bytes
/
.compressor.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
40
41
42
43
44
45
46
47
48
49
50
Set-Location $PSScriptRoot
if (-Not (Test-Path "$env:ProgramFiles\7-Zip\7z.exe")) {
Write-Host "7z.exe not found"
return Read-Host
}
Set-Alias 7z "$env:ProgramFiles\7-Zip\7z.exe"
$name = (Get-Item .).Name
if (-Not (Test-Path (".\" + $name + "\" + $name + ".toc"))) {
Write-Host ".toc not found"
return Read-Host
}
if (Get-Content (".\" + $name + "\" + $name + ".toc") | Where-Object { $_ -match "Version:\s*([a-zA-Z0-9.-]+)" }) {
$version = $matches[1]
} else {
Write-Host "Bad version format"
return Read-Host
}
$foldersToInclude = @(
".\$name"
)
$filesToExclude = @(
"*.doc*"
"*.editorconfig",
"*.git*",
"*.luacheck*",
"*.pkg*",
"*.ps1",
"*.yml"
)
$temp = ".\temp\"
if (Test-Path $temp) {
Remove-Item $temp -Recurse -Force
}
New-Item -Path $temp -ItemType Directory | Out-Null
Copy-Item $foldersToInclude -Destination $temp -Exclude $filesToExclude -Recurse
7z a -tzip -mx9 "..\$name-$version.zip" (Get-ChildItem $temp)
Remove-Item $temp -Recurse -Force