Don't copy files if they're older than what has already been copied
Don't copy a file again if it's not newer than whatever is already in static/. Also, be verbose about which action was taken when -vv flag given.
This commit is contained in:
parent
1d4e11ff7d
commit
499a810873
17
sbs
17
sbs
|
@ -196,8 +196,21 @@ build()
|
|||
# If file does not have .md extension, simply copy it to static/
|
||||
extension=$(basename "$file" | awk -F'.' '{print $NF}')
|
||||
if [ "$extension" != "md" ]; then
|
||||
fileName=$(basename "$file")
|
||||
subDir=$(dirname "$file" | sed "s/.*\/content//")
|
||||
mkdir -p "static/$subDir"
|
||||
|
||||
# Avoid redundant copies when input file hasn't changed
|
||||
if [ "$file" -ot "static/$subDir/$fileName" ]; then
|
||||
if [ "$verbosity" -gt 1 ]; then
|
||||
printf "static%s/%s up to date.\n" "$subDir" "$fileName"
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$verbosity" -gt 1 ]; then
|
||||
printf "Creating: static%s/%s...\n" "$subDir" "$fileName"
|
||||
fi
|
||||
cp "$file" "static/$subDir"
|
||||
continue
|
||||
fi
|
||||
|
@ -323,10 +336,10 @@ case "$1" in
|
|||
fi
|
||||
end_s=$(date +%s)
|
||||
if [ "$verbosity" -gt 0 ]; then
|
||||
printf "Built %d files in %d seconds.\n" \
|
||||
printf "Built %d pages in %d seconds.\n" \
|
||||
$countBuilt "$(($end_s - $start_s))"
|
||||
if [ "$countNotBuilt" -gt 0 ]; then
|
||||
printf "%d files already up to date.\n" \
|
||||
printf "%d pages already up to date.\n" \
|
||||
"$countNotBuilt"
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue