From 8c87183a19906bca1470f625d029f2b19cba71b3 Mon Sep 17 00:00:00 2001 From: Nicolas MASSE Date: Wed, 23 Dec 2020 11:50:08 +0100 Subject: [PATCH] dirty fix for netlify that do not ship realpath --- hugo | 7 ++++++- realpath.py | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100755 realpath.py diff --git a/hugo b/hugo index beb4953..7a326b7 100755 --- a/hugo +++ b/hugo @@ -6,10 +6,15 @@ trap cleanup SIGINT SIGTERM ERR EXIT function cleanup() { trap - SIGINT SIGTERM ERR EXIT + if [ -n "${NETLIFY_BUILD_BASE:-}" ]; then + # Dirty hack for netlify that don't ship the realpath command + realpath=./realpath.py + fi + # On exit, remove any symbolic link in content/french that points # to content/english find content/french -type l -print0 | while IFS= read -r -d $'\0' filename; do - if realpath "$filename" | grep -E "^$PWD/" > /dev/null; then + if ${realpath:-realpath} "$filename" | grep -E "^$PWD/" > /dev/null; then rm -f "$filename" fi done diff --git a/realpath.py b/realpath.py new file mode 100755 index 0000000..83df0ee --- /dev/null +++ b/realpath.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python + +import os +import sys + +# Dirty hack for netlify that don't ship the realpath command +print(os.path.realpath(sys.argv[1]))