From 6ab1f219c45f3b7bc7289eafbc54c2148c423568 Mon Sep 17 00:00:00 2001 From: cya-nide Date: Sat, 25 Apr 2020 12:48:20 +0530 Subject: [PATCH] Check for dependencies (pandoc for now) before running --- generate-epub.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/generate-epub.sh b/generate-epub.sh index d7c21241b80..18690fbb52f 100755 --- a/generate-epub.sh +++ b/generate-epub.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env sh +#! /usr/bin/env bash generate_from_stdin() { outfile=$1 @@ -34,6 +34,20 @@ generate () { cat $name.md | generate_from_stdin $name.epub $language } +# Check if depencies exist +check_dependencies () { + for dependency in "${dependencies[@]}" + do + if ! [ -x "$(command -v $dependency)" ]; then + echo "Error: $dependency is not installed." >&2 + exit 1 + fi + done +} + +dependencies=("pandoc") + +check_dependencies generate_with_solutions generate README-ja ja generate README-zh-Hans zh-Hans