From 9aa0727af29e31b19889b8f4d92f675650949bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Thu, 29 Oct 2020 18:40:14 +0100 Subject: [PATCH] Don't process unmodified files. --- TODO | 1 - sssg.sh | 26 ++++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/TODO b/TODO index 776b411..36e15de 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ ============ *** TODO *** ============ - - File date comparison to avoid unnecessary processing - Manner to loop through files in directory diff --git a/sssg.sh b/sssg.sh index f4b9c77..1354b8b 100755 --- a/sssg.sh +++ b/sssg.sh @@ -65,7 +65,6 @@ function parse { function generate { # create directories - rm -rf _site for i in $(find . -type d -not -path "./_templates" \ -not -path "./_site" -not -path "./_templates/*" \ -not -path "./_site/*") @@ -81,18 +80,21 @@ function generate { "./_site/*") do file_path=${i:2} - if [ ${file_path: -4} == ".htm" ] || - [ ${file_path: -4} == ".HTM" ] || - [ ${file_path: -5} == ".html" ] || - [ ${file_path: -5} == ".HTML" ] + if [ "$file_path" -nt "_site/$file_path" ] then - # parse HTML/CSS files - parse $file_path - else - # files that don't need parsing - echo -n "Copying file to _site/$file_path ... " - cp $file_path _site/$file_path - echo "OK" + if [ ${file_path: -4} == ".htm" ] || + [ ${file_path: -4} == ".HTM" ] || + [ ${file_path: -5} == ".html" ] || + [ ${file_path: -5} == ".HTML" ] + then + # parse HTML/CSS files + parse $file_path + else + # files that don't need parsing + echo -n "Copying file to _site/$file_path ... " + cp $file_path _site/$file_path + echo "OK" + fi fi done }