|
2 | 2 | param(
|
3 | 3 | [parameter()]$jekyllversion = '4',
|
4 | 4 | [parameter()]$servecontainername = 'jekyll-serve',
|
5 |
| - [parameter()][string]$postname = '' |
| 5 | + [parameter()][string]$postname = '', |
| 6 | + [switch]$wait |
6 | 7 | )
|
7 | 8 | $rootdir = git rev-parse --show-toplevel
|
8 | 9 | task proofread {
|
9 | 10 | $learntospellyoudunce = @("kubernets", "kuberen", "oath", "serer", "challange")
|
10 | 11 | $spellingmisstakes = gci "$rootdir/docs/_posts/*.md" | % {
|
11 | 12 | gc $_ | Select-String -Pattern $learntospellyoudunce
|
12 | 13 | }
|
13 |
| - if($spellingmisstakes) { |
| 14 | + if ($spellingmisstakes) { |
14 | 15 | $spellingmisstakes
|
15 | 16 | throw 'learn to spell you dunce'
|
16 | 17 | }
|
@@ -46,15 +47,35 @@ task stop {
|
46 | 47 | }
|
47 | 48 |
|
48 | 49 | task serve stop, remove, {
|
49 |
| - if (test-path .\docs) { |
| 50 | + if (-not (test-path .\docs)) { |
| 51 | + throw "You cannot run what does not exist, run invokebuild new first!" |
| 52 | + } |
| 53 | + else { |
50 | 54 | Push-Location $rootdir/docs
|
51 | 55 | #serve
|
52 | 56 | docker run -d --name $servecontainername --volume="$($PWD):/srv/jekyll" --volume="$PWD/vendor/bundle:/usr/local/bundle" --env JEKYLL_ENV=development -p 4000:4000 jekyll/jekyll:$jekyllversion jekyll serve --watch --drafts
|
53 | 57 |
|
54 | 58 | Pop-Location
|
55 |
| - } |
56 |
| - else { |
57 |
| - throw "You cannot run what does not exist, run invokebuild new first!" |
| 59 | + $tries = 15; |
| 60 | + while ($wait -and $tries -gt 0) { |
| 61 | + Start-Sleep 5 |
| 62 | + try { |
| 63 | + $result = Invoke-WebRequest -Uri "http://localhost:4000" |
| 64 | + if ($result.StatusCode -eq 200) { |
| 65 | + Write-Host "Server is up" |
| 66 | + $tries = 0; |
| 67 | + break; |
| 68 | + } |
| 69 | + else { |
| 70 | + Throw ("Server is not up") |
| 71 | + } |
| 72 | + } |
| 73 | + catch { |
| 74 | + Write-Host "Server is not up" |
| 75 | + Start-Sleep 5; |
| 76 | + $tries--; |
| 77 | + } |
| 78 | + } |
58 | 79 | }
|
59 | 80 | }
|
60 | 81 |
|
|
0 commit comments