Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions 12 Source/Private/GetBuildInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,13 @@ function GetBuildInfo {
}
Write-Debug "Finished parsing Build Manifest $BuildManifest"

$BuildInfo = $BuildInfo | Update-Object $ParameterValues
Write-Debug "Using Module Manifest $($BuildInfo.SourcePath)"

$BuildManifestParent = if ($BuildManifest) {
Split-Path -Parent $BuildManifest
} else {
Get-Location -PSProvider FileSystem
}

if (-Not $BuildInfo.SourcePath) {
if ((-not $BuildInfo.SourcePath) -and $ParameterValues["SourcePath"] -notmatch '\.psd1') {
# Find a module manifest (or maybe several)
$ModuleInfo = Get-ChildItem $BuildManifestParent -Recurse -Filter *.psd1 -ErrorAction SilentlyContinue |
ImportModuleManifest -ErrorAction SilentlyContinue
Expand All @@ -102,13 +99,16 @@ function GetBuildInfo {
}
if (@($ModuleInfo).Count -eq 1) {
Write-Debug "Updating BuildInfo SourcePath to $($ModuleInfo.Path)"
$BuildInfo = $BuildInfo | Update-Object @{ SourcePath = $ModuleInfo.Path }
$ParameterValues["SourcePath"] = $ModuleInfo.Path
}
if (-Not $BuildInfo.SourcePath) {
if (-Not $ModuleInfo) {
throw "Can't find a module manifest in $BuildManifestParent"
}
}

$BuildInfo = $BuildInfo | Update-Object $ParameterValues
Write-Debug "Using Module Manifest $($BuildInfo.SourcePath)"

# Make sure the SourcePath is absolute and points at an actual file
if (!(Split-Path -IsAbsolute $BuildInfo.SourcePath) -and $BuildManifestParent) {
$BuildInfo.SourcePath = Join-Path $BuildManifestParent $BuildInfo.SourcePath | Convert-Path
Expand Down
47 changes: 46 additions & 1 deletion 47 Tests/Integration/Source1.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ Describe "Regression test for #84: Multiple Aliases per command will Export" -Ta
}

Describe "Supports building without a build.psd1" -Tag Integration {
Copy-Item $PSScriptRoot\Source1 TestDrive:\Source1 -Recurse
Copy-Item $PSScriptRoot\Source1 TestDrive:\Source1 -Recurse
# This is the old build, with a build.psd1
$Output = Build-Module TestDrive:\Source1\build.psd1 -Passthru
$ManifestContent = Get-Content $Output.Path
$ModuleContent = Get-Content ([IO.Path]::ChangeExtension($Output.Path, ".psm1"))
Remove-Item (Split-Path $Output.Path) -Recurse

# Then remove the build.psd1 and rebuild it
Remove-Item TestDrive:\Source1\build.psd1

$Build = @{ }
Expand All @@ -105,6 +112,8 @@ Describe "Supports building without a build.psd1" -Tag Integration {

It "Creates the same module as with a build.psd1" {
$Build.Metadata = Import-Metadata $Build.Output.Path
Get-Content $Build.Output.Path | Should -Be $ManifestContent
Get-Content ([IO.Path]::ChangeExtension($Build.Output.Path, ".psm1")) | Should -Be $ModuleContent
}

It "Should update AliasesToExport in the manifest" {
Expand All @@ -115,6 +124,42 @@ Describe "Supports building without a build.psd1" -Tag Integration {
$Build.Metadata.FunctionsToExport | Should -Be @("Get-Source", "Set-Source")
}
}
Describe "Supports building discovering the module without a build.psd1" -Tag Integration {
Copy-Item $PSScriptRoot\Source1 TestDrive:\source -Recurse

# This is the old build, with a build.psd1
$Output = Build-Module TestDrive:\source\build.psd1 -Passthru
$ManifestContent = Get-Content $Output.Path
$ModuleContent = Get-Content ([IO.Path]::ChangeExtension($Output.Path, ".psm1"))
Remove-Item (Split-Path $Output.Path) -Recurse

# Then remove the build.psd1 and rebuild it
Remove-Item TestDrive:\source\build.psd1

Push-Location -StackName 'IntegrationTest' -Path TestDrive:\

$Build = @{ }

It "No longer fails if there's no build.psd1" {
$Build.Output = Build-Module -Passthru
}

It "Creates the same module as with a build.psd1" {
$Build.Metadata = Import-Metadata $Build.Output.Path
Get-Content $Build.Output.Path | Should -Be $ManifestContent
Get-Content ([IO.Path]::ChangeExtension($Build.Output.Path, ".psm1")) | Should -Be $ModuleContent
}

It "Should update AliasesToExport in the manifest" {
$Build.Metadata.AliasesToExport | Should -Be @("GS", "GSou", "SS", "SSou")
}

It "Should update FunctionsToExport in the manifest" {
$Build.Metadata.FunctionsToExport | Should -Be @("Get-Source", "Set-Source")
}

Pop-Location -StackName 'IntegrationTest'
}

Describe "Regression test for #88 not copying prefix files" -Tag Integration, Regression {
$Output = Build-Module $PSScriptRoot\build.psd1 -Passthru
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.