Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating code and using dotnet tool installer for wyam #6

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: CI

on: [push, pull_request]

jobs:
build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v1
- name: Invoke-Build
run: .\build.ps1
shell: powershell
4 changes: 1 addition & 3 deletions PoshWyam.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ Task RunTests InstallDependencies, Stage, {

}

$testResults = Invoke-Pester @invokePesterParams

$testResults | ConvertTo-Json -Depth 5 | Set-Content (Join-Path $Artifacts 'PesterResults.json')
Invoke-Pester -OutputFile (Join-Path $Artifacts 'PesterResults.xml')
}

Task ConfirmTestsPassed {
Expand Down
4 changes: 2 additions & 2 deletions PoshWyam/Private/ConvertFrom-Yaml.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ function ConvertFrom-Yaml {
if ($Yaml) {
$stringReader = New-Object System.IO.StringReader($Yaml)
try {
$deserializer = [YamlDotNet.Serialization.Deserializer]::new()
$deserializer = [YamlDotNet.Serialization.DeserializerBuilder]::new().Build()
$yamlObject = $deserializer.Deserialize($stringReader);
$serializer = [YamlDotNet.Serialization.Serializer]::new('JsonCompatible')
$serializer = [YamlDotNet.Serialization.SerializerBuilder]::new().JsonCompatible().Build()
$stringBuilder = [System.Text.StringBuilder]::new()
$stringWriter = [System.IO.StringWriter]::new($stringBuilder)
$serializer.Serialize($stringWriter, $yamlObject)
Expand Down
4 changes: 2 additions & 2 deletions PoshWyam/Public/Invoke-Wyam.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ function Invoke-Wyam {
if (-not $root -or -not (Test-Path $root)) {
$root = Join-Path $ModuleRoot 'Wyam'
}
$wyam = Get-ChildItem -Path $root -Include wyam.exe -Recurse | Select-Object -First 1
$wyam = Get-ChildItem -Path $root -Include wyam.dll -Recurse | Select-Object -First 1
$wyam = Resolve-Path $wyam
Write-Verbose "Invoke-Wyam: Tool located at '$wyam'"
$Arguments = ($Arguments | Quote) -join ' '
Expand All @@ -266,7 +266,7 @@ function Invoke-Wyam {
Install-Wyam -Root $root
}

$expr = "&`"$wyam`" $Arguments"
$expr = "&`"dotnet`" `"$wyam`" $Arguments"
Write-Verbose "Invoke-Wyam: Running command '$expr'"
Invoke-Expression $expr
}
Expand Down
18 changes: 13 additions & 5 deletions PoshWyam/Public/New-BlogPost.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,26 @@ function New-BlogPost {
[Parameter(Position=0, Mandatory=$True)]
[string]
$Title,

# The tags to include in the blog post.
[Parameter(Position=1, Mandatory=$False)]
[string[]]
$Tag = @(),

[switch]
$IncludeDateInFileName,

# The Wyam project root.
$Root = (Get-WyamRoot),

# Post a draft instead.
[switch]
$Draft
)

begin {
}

process {
# Get directory
$parms = @{ 'Root' = $Root }
Expand All @@ -36,8 +39,13 @@ function New-BlogPost {
}
$posts = Get-BlogPostsLocation @parms

$fileName = Get-FileName -Title $Title -Extension ".md"

if($IncludeDateInFileName){
$fileName = "$((Get-Date).ToString("yyyy-MM-dd"))-$fileName"
}
# Get path to post to create
$path = Join-Path $posts (Get-BlogPostName $Title)
$path = Join-Path $posts $fileName

# Create post
$content = @"
Expand All @@ -52,7 +60,7 @@ Tags: [$(($Tag | ForEach-Object { """$_""" }) -join ', ')]
Set-Content -Path $path -Value $content
Resolve-Path $path
}

end {
}
}
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if (-not (Get-Module InvokeBuild)) {
Import-Module InvokeBuild -ErrorAction SilentlyContinue
if (-not (Get-Module InvokeBuild)) {
Install-Module InvokeBuild -Scope CurrentUser
Install-Module InvokeBuild -Scope CurrentUser -Force
Import-Module InvokeBuild -ErrorAction Stop
}
}
Expand Down
27 changes: 27 additions & 0 deletions tests/Public/New-BlogPost.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Import-Module "$Artifacts\PoshWyam\PoshWyam.psd1" -Force

Describe "New-BlogPost" {

BeforeAll {
[void](New-Item -Path "TestDrive:\config.wyam" -ItemType File)
[void](New-Item -Path "TestDrive:\input\posts" -ItemType Directory)

Push-Location "TestDrive:\"
}

AfterAll {
Pop-Location
}

Context "With -Title" {
It "runs without error" {

$before = (Get-ChildItem "TestDrive:\input\posts").Count
New-BlogPost -Title "test post"

(Get-ChildItem "TestDrive:\input\posts").Count | Should be ($before + 1)

}
}

}