From a3a73c9202c8ade4afa93f22540d4110a20cc8f9 Mon Sep 17 00:00:00 2001 From: Muriel Salvan Date: Fri, 7 May 2021 15:46:16 +0200 Subject: [PATCH] Support extra arguments to mmdc through the MMDC_EXTRA_ARGS environment variable (#34) * Support extra arguments to mmdc through the optional MMDC_EXTRA_ARGS environment variable --- README.md | 5 ++++- entrypoint.sh | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6645382..2de5fdc 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,10 @@ Looking for suggestions/help in improving this action. If there is a feature you ## How to use The idea is that this action is to be used within a workflow, not as a standalone action at this time. -OUTPUT_FILE_TYPE can be used to define the output file type, if you don't specify it it will default to png. You can override it to svg or pdf. + +Some environment variables can be set to tune the compilation: +* `OUTPUT_FILE_TYPE` can be used to define the output file type, if you don't specify it it will default to png. You can override it to svg or pdf. +* `MMDC_EXTRA_ARGS` can be used to add extra command line arguments to the `mmdc` command line generating diagrams. Do not include `-i`, `-o` and `-p` arguments as they are already handled outside of this variable. ### Sample workflow with automated PR diff --git a/entrypoint.sh b/entrypoint.sh index 6d67c3d..2d07716 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,6 +18,9 @@ set -euo pipefail +# Normalize some environment variables (default values) +MMDC_EXTRA_ARGS="${MMDC_EXTRA_ARGS:-}" + function main { printf "Using MMDC version %s\n" "$(/node_modules/.bin/mmdc -V)" @@ -77,7 +80,8 @@ function is_path_markdown { function c_mermaid { printf "Compiling: %s\n" "${1}" printf "Output to: %s\n" "${2}" - /node_modules/.bin/mmdc -p /mmdc/puppeteer-config.json -i "${1}" -o "${2}" + printf "Extra args: %s\n" "${MMDC_EXTRA_ARGS}" + /node_modules/.bin/mmdc -p /mmdc/puppeteer-config.json -i "${1}" -o "${2}" ${MMDC_EXTRA_ARGS} confirm_creation "${2}" }