Skip to content

Commit

Permalink
theme: improve tests #685
Browse files Browse the repository at this point in the history
by
- removing duplicate code
- make it runnable from foreign Hugo project repos
  • Loading branch information
McShelby committed Oct 13, 2023
1 parent c2a7173 commit b0c3f96
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 39 deletions.
31 changes: 31 additions & 0 deletions exampleSite/test-hugo.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@echo off
setlocal enabledelayedexpansion

set hugo_prefix=
set hugo_version=
if not "%~1"=="" (
set hugo_prefix=.hugo
set hugo_version=.%1
)

set "versionFile=..\layouts\partials\version.txt"
if not exist "%versionFile%" (
set "versionFile=..\hugo-theme-relearn\layouts\partials\version.txt"
)
set /p version=<"%versionFile%"
echo %version%>"metrics.%version%%hugo_prefix%%hugo_version%.log"

hugo%hugo_version% --environment testing --templateMetrics --templateMetricsHints --cleanDestinationDir --destination "public.%version%%hugo_prefix%%hugo_version%" >> "metrics.%version%%hugo_prefix%%hugo_version%.log"

set "start_dir=%CD%\public.%version%%hugo_prefix%%hugo_version%"
set "output_file=dir.%version%%hugo_prefix%%hugo_version%.log"
if exist "%output_file%" del "%output_file%"
for /r "%start_dir%" %%F in (*) do (
set "file=%%F"
echo !file:%start_dir%\=! >> "%output_file%"
)
move /Y "dir.%version%%hugo_prefix%%hugo_version%.log" "public.%version%%hugo_prefix%%hugo_version%\dir.log" 2>&1 >NUL

move /Y "metrics.%version%%hugo_prefix%%hugo_version%.log" "public.%version%%hugo_prefix%%hugo_version%\metrics.log" 2>&1 >NUL
For /F "UseBackQ Delims==" %%A In ("public.%version%%hugo_prefix%%hugo_version%\metrics.log") Do Set "lastline=%%A"
echo %lastline%
4 changes: 4 additions & 0 deletions exampleSite/test-hugo.min.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
setlocal enabledelayedexpansion

call "test-hugo.bat" 0.95.0
18 changes: 0 additions & 18 deletions exampleSite/test.bat

This file was deleted.

21 changes: 0 additions & 21 deletions exampleSite/test.min.bat

This file was deleted.

0 comments on commit b0c3f96

Please sign in to comment.