mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-31 08:57:15 +00:00
test: make theme dir detection more robust
This commit is contained in:
parent
74cd1cce00
commit
22a36ca7b2
1 changed files with 38 additions and 16 deletions
|
@ -8,37 +8,59 @@ if not "%~1"=="" (
|
|||
set hugo_version=.%1
|
||||
)
|
||||
|
||||
set "versionFile=..\layouts\partials\version.txt"
|
||||
if not exist "%versionFile%" (
|
||||
set "versionFile=..\hugo-theme-relearn\layouts\partials\version.txt"
|
||||
rem Relearn themes exampleSite
|
||||
set "themeDir=.."
|
||||
if not exist "%themeDir%\layouts\partials\version.txt" (
|
||||
rem other sites stored parallel to Relearn themes directory
|
||||
set "themeDir=..\hugo-theme-relearn"
|
||||
)
|
||||
set /p version=<"%versionFile%"
|
||||
echo %version%>"metrics.%version%%hugo_prefix%%hugo_version%.log"
|
||||
if not exist "%themeDir%\layouts\partials\version.txt" (
|
||||
rem other sites stored inside of repos directory parallel to Relearn theme directory
|
||||
set "themeDir=..\..\hugo-theme-relearn"
|
||||
)
|
||||
if not exist "%themeDir%\layouts\partials\version.txt" (
|
||||
rem regular theme users
|
||||
set "themeDir=themes\hugo-theme-relearn"
|
||||
)
|
||||
if not exist "%themeDir%\layouts\partials\version.txt" (
|
||||
rem theme users with custom theme name
|
||||
set "themeDir=themes\relearn"
|
||||
)
|
||||
if not exist "%themeDir%\layouts\partials\version.txt" (
|
||||
echo Relearn theme not found.
|
||||
set "version="
|
||||
) else (
|
||||
set /p version=<"%themeDir%\layouts\partials\version.txt"
|
||||
set "version=.!version!"
|
||||
)
|
||||
echo %version%>"metrics%version%%hugo_prefix%%hugo_version%.log"
|
||||
|
||||
set config=--environment testing
|
||||
if exist "config\testing" (
|
||||
rem Seems we are in the themes exampleSite, no need to copy anything
|
||||
rem seems we are in the themes exampleSite, no need to copy anything
|
||||
) else if exist "config.toml" (
|
||||
set config=--config config.toml,..\hugo-theme-relearn\exampleSite\config\testing\hugo.toml
|
||||
set config=--config config.toml,%themeDir%\exampleSite\config\testing\hugo.toml
|
||||
) else if exist "hugo.toml" (
|
||||
set config=--config hugo.toml,..\hugo-theme-relearn\exampleSite\config\testing\hugo.toml
|
||||
set config=--config hugo.toml,%themeDir%\exampleSite\config\testing\hugo.toml
|
||||
) else if exist "config" (
|
||||
copy /e /i /y "..\hugo-theme-relearn\exampleSite\config\testing" "config\testing"
|
||||
copy /e /i /y "%themeDir%\exampleSite\config\testing" "config\testing"
|
||||
) else if exist "hugo" (
|
||||
copy /e /i /y "..\hugo-theme-relearn\exampleSite\config\testing" "hugo\testing"
|
||||
copy /e /i /y "%themeDir%\config\testing" "hugo\testing"
|
||||
)
|
||||
|
||||
hugo%hugo_version% %config% --templateMetrics --templateMetricsHints --printI18nWarnings --printPathWarnings --printUnusedTemplates --cleanDestinationDir --destination "public.%version%%hugo_prefix%%hugo_version%" >> "metrics.%version%%hugo_prefix%%hugo_version%.log"
|
||||
echo on
|
||||
hugo%hugo_version% %config% --printPathWarnings --templateMetrics --templateMetricsHints --cleanDestinationDir --destination "public%version%%hugo_prefix%%hugo_version%" >> "metrics%version%%hugo_prefix%%hugo_version%.log"
|
||||
@echo off
|
||||
|
||||
set "start_dir=%CD%\public.%version%%hugo_prefix%%hugo_version%"
|
||||
set "output_file=dir.%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 "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"
|
||||
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%
|
||||
|
|
Loading…
Add table
Reference in a new issue