-
-
Notifications
You must be signed in to change notification settings - Fork 544
Expand file tree
/
Copy pathbuild-repos.ps1
More file actions
executable file
·37 lines (33 loc) · 1.05 KB
/
build-repos.ps1
File metadata and controls
executable file
·37 lines (33 loc) · 1.05 KB
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
<#
.SYNOPSIS
Build Git repos
.DESCRIPTION
This PowerShell script builds all Git repositories within a folder.
.PARAMETER parentDir
Specifies the path to the parent folder
.EXAMPLE
PS> ./build-repos.ps1 C:\MyRepos
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$parentDir = "$PWD")
try {
$stopWatch = [system.diagnostics.stopwatch]::startNew()
$parentDirName = (Get-Item "$parentDir").Name
"⏳ Step 1 - Checking parent folder 📂$parentDirName..."
if (-not(Test-Path "$parentDir" -pathType container)) { throw "Can't access folder: $parentDir" }
$folders = (Get-ChildItem "$parentDir" -attributes Directory)
$numFolders = $folders.Count
"Found $numFolders subfolders."
foreach ($folder in $folders) {
& "$PSScriptRoot/build-repo.ps1" "$folder"
}
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
"✅ $numFolders Git repositories built at 📂$parentDir in $($elapsed)s."
exit 0 # success
} catch {
"⚠️ ERROR: $($Error[0]) (at line $($_.InvocationInfo.ScriptLineNumber))"
exit 1
}