mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-24 08:53:59 +01:00
39 lines
1.0 KiB
PowerShell
Executable File
39 lines
1.0 KiB
PowerShell
Executable File
<#
|
|
.SYNOPSIS
|
|
make-repos.ps1 [<parent-dir>]
|
|
.DESCRIPTION
|
|
Builds all Git repositories under the current/given directory.
|
|
.EXAMPLE
|
|
PS> .\make-repos.ps1 C:\MyRepos
|
|
.NOTES
|
|
Author: Markus Fleschutz · License: CC0
|
|
.LINK
|
|
https://github.com/fleschutz/PowerShell
|
|
#>
|
|
|
|
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/make-repo.ps1" "$Folder"
|
|
$Step++
|
|
}
|
|
|
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
|
"✔️ built $FolderCount Git repositories at 📂$ParentDirName in $Elapsed sec"
|
|
exit 0
|
|
} catch {
|
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
exit 1
|
|
}
|