-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathShared.ps1
More file actions
49 lines (44 loc) · 1.32 KB
/
Copy pathShared.ps1
File metadata and controls
49 lines (44 loc) · 1.32 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
38
39
40
41
42
43
44
45
46
47
48
49
#Requires -Version 7.0
<#
.SYNOPSIS
Shared utility functions for AU package scripts
.DESCRIPTION
Common functions used across package update scripts.
#>
function Get-RepositoryRoot
{
<#
.SYNOPSIS
Finds the repository root by searching for .git directory
#>
$current = $PSScriptRoot
while ($current -and -not (Test-Path -PathType Container -LiteralPath (Join-Path $current '.git')))
{
$current = Split-Path -Path $current -Parent
}
if (-not $current)
{
throw "Could not find repository root (no .git directory found)"
}
return $current
}
function Import-AUModule
{
<#
.SYNOPSIS
Imports the Chocolatey-AU module from submodule or global install
#>
if (-not (Get-Module -Name Chocolatey-AU -ListAvailable))
{
$repoRoot = Get-RepositoryRoot
$auModulePath = Join-Path -Path $repoRoot -ChildPath '_modules'
$auModulePath = Join-Path -Path $auModulePath -ChildPath 'au'
$auModulePath = Join-Path -Path $auModulePath -ChildPath 'src'
$auModulePath = Join-Path -Path $auModulePath -ChildPath 'Chocolatey-AU.psd1'
if (-not (Test-Path $auModulePath))
{
throw "AU module not found at $auModulePath. Run 'git submodule update --init' first."
}
Import-Module -Force $auModulePath
}
}