Skip to content

Commit 35d5033

Browse files
committed
Stop mocking so many tests...
1 parent f108b73 commit 35d5033

8 files changed

Lines changed: 235 additions & 313 deletions

File tree

Source/ModuleBuilder.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# Release Notes have to be here, so we can update them
1313
ReleaseNotes = '
14-
Add Script Generators and convert our Move-UsingStatment and Update-AliasesToExport to generators
14+
Add Script Generators and convert our Move-UsingStatement and Update-AliasesToExport to generators
1515
Add Merge-ScriptBlock and Add-Parameter generators to support extracting more common boilerplate code
1616
'
1717

Source/Public/Build-Module.ps1

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ function Build-Module {
165165
}
166166
process {
167167
try {
168+
# Push-Location up front to create the Stack because we Pop-Location in finally
169+
Push-Location -StackName Build-Module
168170
# Push into the module source (it may be a subfolder)
169171
$ModuleInfo = InitializeBuild $SourcePath
170172
Write-Progress "Building $($ModuleInfo.Name)" -Status "Use -Verbose for more information"
@@ -183,7 +185,7 @@ function Build-Module {
183185
Write-Verbose "Target $($ModuleInfo.Target)"
184186
$NewestBuild = (Get-Item $RootModule -ErrorAction SilentlyContinue).LastWriteTime
185187
$IsNew = Get-ChildItem $ModuleInfo.ModuleBase -Recurse |
186-
Where-Object LastWriteTime -gt $NewestBuild |
188+
Where-Object LastWriteTime -GT $NewestBuild |
187189
Select-Object -First 1 -ExpandProperty LastWriteTime
188190

189191
if ($null -eq $IsNew) {
@@ -227,7 +229,7 @@ function Build-Module {
227229
# SilentlyContinue because there don't *HAVE* to be public functions
228230
if (($PublicFunctions = Get-ChildItem $ModuleInfo.PublicFilter -Recurse -ErrorAction SilentlyContinue |
229231
Where-Object BaseName -In $AllScripts.BaseName |
230-
Select-Object -ExpandProperty BaseName)) {
232+
Select-Object -ExpandProperty BaseName)) {
231233

232234
Update-Metadata -Path $OutputManifest -PropertyName FunctionsToExport -Value $PublicFunctions
233235
}
@@ -251,7 +253,7 @@ function Build-Module {
251253
}
252254
} elseif ($ModuleInfo.Prerelease) {
253255
Write-Warning ("Cannot set Prerelease in module manifest. Add an empty Prerelease to your module manifest, like:`n" +
254-
' PrivateData = @{ PSData = @{ Prerelease = "" } }')
256+
' PrivateData = @{ PSData = @{ Prerelease = "" } }')
255257
}
256258

257259
if ($ModuleInfo.BuildMetadata) {
@@ -293,7 +295,7 @@ function Build-Module {
293295

294296
if ($Custom = $ModuleInfo.Generators.Where{ $_.Generator -eq "Update-AliasesToExport" }) {
295297
$UpdateAlias = $Custom
296-
$ModuleInfo.Generators = $ModuleInfo.Generators.Where{ $_.Generator -ne "Update-AliasesToExportUpdate-AliasesToExport" }
298+
$ModuleInfo.Generators = $ModuleInfo.Generators.Where{ $_.Generator -ne "Update-AliasesToExport" }
297299
}
298300
$ModuleInfo.Generators = @($MoveUsing) + @($ModuleInfo.Generators) + @($UpdateAlias)
299301
}

Source/Public/Invoke-ScriptGenerator.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ function Invoke-ScriptGenerator {
5151
[Alias("PSPath", "File")]
5252
[string]$Path,
5353

54-
# The name of the Script Generator to invoke. Must be a command that takes an AST as a pipeline inputand outputs TextReplacement objects.
55-
# There are two built into ModuleBuilder:
56-
# - MergeBlocks. Supports Before/After/Around blocks for aspects like error handling or authentication.
54+
# The name of the Script Generator to invoke. Must be a command that takes an AST as a pipeline input and outputs TextReplacement objects.
55+
# There are several built into ModuleBuilder.
56+
# Two that you can use to create your own code generators:
57+
# - Merge-ScriptBlock. Supports Before/After/Around blocks for aspects like error handling or authentication.
5758
# - Add-Parameter. Supports adding parameters to functions (usually in conjunction with MergeBlock that use those parameters)
59+
# And another two that are always executed:
60+
# - Move-UsingStatement. Moves all using statements to the top of the source code, so they work.
61+
# - Update-AliasesToExport. Finds all aliases in the script module (side-effect: updates AliasesToExport in the module manifest)
5862
[Parameter(ValueFromPipelineByPropertyName)]
5963
[string]$Generator,
6064

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using module ModuleBuilder
2+
3+
function Get-Source {
4+
[CmdletBinding()]
5+
[Alias("gs","gsou")]
6+
param()
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using module ModuleBuilder
2+
function Set-Source {
3+
[CmdletBinding()]
4+
[Alias("ss", "ssou")]
5+
param()
6+
"sto͞o′pĭd"
7+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
@{
2+
# The module version should be SemVer.org compatible
3+
ModuleVersion = "1.0.0"
4+
5+
# PrivateData is where all third-party metadata goes
6+
PrivateData = @{
7+
# PrivateData.PSData is the PowerShell Gallery data
8+
PSData = @{
9+
# Prerelease string should be here, so we can set it
10+
Prerelease = ''
11+
12+
# Release Notes have to be here, so we can update them
13+
ReleaseNotes = '
14+
A test module
15+
'
16+
17+
# Tags applied to this module. These help with module discovery in online galleries.
18+
Tags = 'Authoring','Build','Development','BestPractices'
19+
20+
# A URL to the license for this module.
21+
LicenseUri = 'https://github.com/PoshCode/ModuleBuilder/blob/master/LICENSE'
22+
23+
# A URL to the main website for this project.
24+
ProjectUri = 'https://github.com/PoshCode/ModuleBuilder'
25+
26+
# A URL to an icon representing this module.
27+
IconUri = 'https://github.com/PoshCode/ModuleBuilder/blob/resources/ModuleBuilder.png?raw=true'
28+
} # End of PSData
29+
} # End of PrivateData
30+
31+
# The main script module that is automatically loaded as part of this module
32+
RootModule = 'Source2.psm1'
33+
34+
# Modules that must be imported into the global environment prior to importing this module
35+
RequiredModules = @()
36+
37+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
38+
DefaultCommandPrefix = 'Source2'
39+
40+
# Always define FunctionsToExport as an empty @() which will be replaced on build
41+
FunctionsToExport = @()
42+
AliasesToExport = @()
43+
44+
# ID used to uniquely identify this module
45+
GUID = 'a264e183-e0f7-4219-bc80-c30d14e0e98e'
46+
Description = 'A module for authoring and building PowerShell modules'
47+
48+
# Common stuff for all our modules:
49+
CompanyName = 'PoshCode'
50+
Author = 'Joel Bennett'
51+
Copyright = "Copyright 2018 Joel Bennett"
52+
53+
# Minimum version of the Windows PowerShell engine required by this module
54+
PowerShellVersion = '5.1'
55+
CompatiblePSEditions = @('Core','Desktop')
56+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@{
2+
Path = "Source2.psd1"
3+
OutputDirectory = "..\Result2"
4+
}

0 commit comments

Comments
 (0)