Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VERSION
*.nupkg
obj
obj
# ignore release dirs
/*.*.*
34 changes: 34 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
$moduleVersion = (Import-LocalizedData -FileName 'posh-git.psd1' -BaseDirectory (Join-Path $PSScriptRoot 'src')).ModuleVersion
$outputFolder = (Join-Path $PSScriptRoot $moduleVersion)

# Clean
if (Test-Path $outputFolder) {
Remove-Item $outputFolder -Recurse
}

# Copy files to output folder
Copy-Item -Path (Join-Path $PSScriptRoot 'src') -Destination $outputFolder -Recurse

$mainModulePath = (Join-Path $outputFolder 'posh-git.psm1')
$contentOfMainModule = Get-Content -Path $mainModulePath

$PowerShellScriptsToBeMerged = Get-ChildItem -Path $outputFolder -Filter '*.ps1'
foreach ($powerShellScriptToBeMerged in $PowerShellScriptsToBeMerged) {
$NameOfScriptToBeMerged = $powerShellScriptToBeMerged.Name
$scriptContentToBeMerged = Get-Content -Path $powerShellScriptToBeMerged -Raw
$replaceSearchText = ". `$PSScriptRoot\$NameOfScriptToBeMerged"
if ($contentOfMainModule.Contains($replaceSearchText)) {
$contentOfMainModule = $contentOfMainModule.Replace(". `$PSScriptRoot\$NameOfScriptToBeMerged",
@"
#region $($powerShellScriptToBeMerged.BaseName)
$scriptContentToBeMerged
#endregion

"@)
Remove-Item $powerShellScriptToBeMerged
}
}

Set-Content -Path $mainModulePath -Value $contentOfMainModule

Write-Verbose "Module created at '$outputFolder'" -Verbose
5 changes: 5 additions & 0 deletions test/Shared.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
$modulePath = Convert-Path $PSScriptRoot\..\src
# Test against built folder in CI (or just set $env:CI locally for that)
if ($env:CI) {
Copy link
Copy Markdown
Collaborator

@rkeithhill rkeithhill Sep 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works on a build machine. Can we also add a PowerShell variable check here like:

if ($env:CI -or $PoshGitBuild)

That way if we build & test from the build.ps1 script on a dev machine, it will run the Pester tests against the release dir. And because that $PoshGitBuild variable goes away after the build script exits, I can still run tests from the src folder module when I doing dev work.

$moduleVersion = (Import-LocalizedData -FileName 'posh-git.psd1' -BaseDirectory ($modulePath)).ModuleVersion
$modulePath = Convert-Path $PSScriptRoot\..\$moduleVersion
}
$moduleManifestPath = "$modulePath\posh-git.psd1"

$csi = [char]0x1b + "["
Expand Down