forked from majkinetor/au
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed7ee79
commit 040063b
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<# | ||
.SYNOPSIS | ||
Updates nuspec file description from README.md | ||
.DESCRIPTION | ||
This script should be called in au_AfterUpdate to put the text in the README.md | ||
into description tag of the Nuspec file. The current description will be replaced. | ||
Function will throw an error if README.md is not found. | ||
.PARAMETER SkipFirst | ||
Number of start lines to skip from the README.md, by default 0. | ||
.PARAMETER SkipLast | ||
Number of end lines to skip from the README.md, by default 0. | ||
.EXAMPLE | ||
function global:au_AfterUpdate { Set-DescriptionFromReadme -SkipFirst 2 } | ||
#> | ||
function Set-DescriptionFromReadme([int]$SkipFirst=0, [int]$SkipLast=0) { | ||
if (!(Test-Path README.md)) { throw 'Set-DescriptionFromReadme: README.md not found' } | ||
|
||
Write-Host 'Setting README.md to Nuspec description tag' | ||
$description = gc README.md -Encoding UTF8 | ||
$endIdx = $description.Length - $SkipLast | ||
$description = $description | select -Index ($SkipFirst..$endIdx) | Out-String | ||
|
||
$nuspecFileName = $Latest.PackageName + ".nuspec" | ||
$nu = gc $nuspecFileName -Raw -Encoding UTF8 | ||
$nu = $nu -replace "(?smi)(\<description\>).*?(\</description\>)", "`${1}$($description)`$2" | ||
|
||
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($False) | ||
$NuPath = (Resolve-Path $NuspecFileName) | ||
[System.IO.File]::WriteAllText($NuPath, $nu, $Utf8NoBomEncoding) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters