From ece101a5cc9a81bdeae17c81c16d4cfb93f886d0 Mon Sep 17 00:00:00 2001 From: Matteo Mortari Date: Tue, 5 Mar 2024 20:43:06 +0100 Subject: [PATCH] fix: make sh script compatible with Mac OSX sed (#21) Signed-off-by: Matteo Mortari --- scripts/gen_openapi_server.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/gen_openapi_server.sh b/scripts/gen_openapi_server.sh index 6bac6684..94ce1493 100755 --- a/scripts/gen_openapi_server.sh +++ b/scripts/gen_openapi_server.sh @@ -11,8 +11,14 @@ openapi-generator-cli generate \ --ignore-file-override $ROOT_FOLDER/.openapi-generator-ignore --additional-properties=outputAsLibrary=true,enumClassPrefix=true,router=chi,sourceFolder=,onlyInterfaces=true,isGoSubmodule=true,enumClassPrefix=true,useOneOfDiscriminatorLookup=true \ --template-dir $ROOT_FOLDER/templates/go-server -sed -i 's/, orderByParam/, model.OrderByField(orderByParam)/g' $ROOT_FOLDER/internal/server/openapi/api_model_registry_service.go -sed -i 's/, sortOrderParam/, model.SortOrder(sortOrderParam)/g' $ROOT_FOLDER/internal/server/openapi/api_model_registry_service.go +if [[ $(uname) == "Darwin" ]]; then + # introduce -i parameter for Mac OSX sed compatibility + sed -i '' 's/, orderByParam/, model.OrderByField(orderByParam)/g' $ROOT_FOLDER/internal/server/openapi/api_model_registry_service.go + sed -i '' 's/, sortOrderParam/, model.SortOrder(sortOrderParam)/g' $ROOT_FOLDER/internal/server/openapi/api_model_registry_service.go +else + sed -i 's/, orderByParam/, model.OrderByField(orderByParam)/g' $ROOT_FOLDER/internal/server/openapi/api_model_registry_service.go + sed -i 's/, sortOrderParam/, model.SortOrder(sortOrderParam)/g' $ROOT_FOLDER/internal/server/openapi/api_model_registry_service.go +fi echo "Assembling type_assert Go file" ./scripts/gen_type_asserts.sh