-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpsakefile.ps1
28 lines (22 loc) · 1.1 KB
/
psakefile.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
Task default -depends FunctionsToExport, Analyze
Task FunctionsToExport {
$moduleName = Get-Item . | ForEach-Object BaseName
# RegEx matches files like Verb-Noun.ps1 only, not psakefile.ps1 or *-*.Tests.ps1
$functionNames = Get-ChildItem $moduleName -Recurse | Where-Object { $_.Name -match "^[^\.]+-[^\.]+\.ps1$" } -PipelineVariable file | ForEach-Object {
$ast = [System.Management.Automation.Language.Parser]::ParseFile($file.FullName, [ref] $null, [ref] $null)
if ($ast.EndBlock.Statements.Name) {
$ast.EndBlock.Statements.Name
}
}
Write-Verbose "Using functions $functionNames"
# Make sure no functions are duplicated
$functionNames | Group-Object | ForEach-Object {
$_.Group | Should -HaveCount 1
}
# Temporary disabled because it's blasting some of the PSData tags!
# Update-ModuleManifest -Path "$($moduleName)\$($moduleName).psd1" -FunctionsToExport $functionNames
Import-Module $moduleName -Force -Verbose:$false
}
Task Analyze {
Invoke-ScriptAnalyzer . -Recurse -Severity Warning -ExcludeRule "PSAvoidUsingWriteHost"
}