forked from fleschutz/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-repos.ps1
executable file
·40 lines (34 loc) · 1.1 KB
/
build-repos.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
<#
.SYNOPSIS
Builds all Git repositories in a folder
.DESCRIPTION
This PowerShell script builds all Git repositories in a given folder.
.PARAMETER ParentDir
Specifies the path to the folder containing the Git repositories
.EXAMPLE
PS> ./build-repos C:\MyRepos
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
#>
param([string]$ParentDir = "$PWD")
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" }
$Folders = (get-childItem "$ParentDir" -attributes Directory)
$FolderCount = $Folders.Count
$ParentDirName = (get-item "$ParentDir").Name
"Found $FolderCount subfolders in 📂$ParentDirName..."
[int]$Step = 1
foreach ($Folder in $Folders) {
& "$PSScriptRoot/build-repo.ps1" "$Folder"
$Step++
}
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ built $FolderCount Git repositories at 📂$ParentDirName in $Elapsed sec"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}