Skip to content

Commit 76c8d60

Browse files
committed
Merge branch 'generate-sample-fixes' of https://github.com/stephenfin/openapi-generator into stephenfin-generate-sample-fixes
2 parents a1c948d + 588b3a9 commit 76c8d60

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

bin/generate-samples.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,26 @@ For example:
4747

4848
echo "$header"
4949

50+
tmpfile=$(mktemp)
51+
trap "rm -f $tmpfile" EXIT
52+
5053
if [[ ${#files[@]} -eq 1 && "${files[0]}" != *'*'* ]]; then
51-
# shellcheck disable=SC2086
52-
# shellcheck disable=SC2068
53-
java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]}
54+
# shellcheck disable=SC2086
55+
# shellcheck disable=SC2068
56+
java ${JAVA_OPTS} -jar "$executable" generate -c ${files[0]} ${args[@]} 2>&1 | tee "$tmpfile"
57+
retcode=${PIPESTATUS[0]}
5458
else
55-
echo "Please press CTRL+C to stop or the script will continue in 5 seconds."
56-
#sleep 5
57-
if [ ${#files[@]} -eq 0 ]; then
58-
files=("${root}"/bin/configs/*.yaml)
59-
fi
59+
if [ ${#files[@]} -eq 0 ]; then
60+
files=("${root}"/bin/configs/*.yaml)
61+
fi
6062

61-
# shellcheck disable=SC2086
62-
# shellcheck disable=SC2068
63-
if java ${JAVA_OPTS} -jar "$executable" batch ${BATCH_OPTS} --includes-base-dir "${root}" --fail-fast -- ${files[@]} 2>&1 | tee /dev/pts/0 | grep -q -i "exception"; then
64-
echo "Found exception(s) when running the generator(s) to update the samples."
65-
export GENERATE_ERROR=1
66-
fi
63+
# shellcheck disable=SC2086
64+
# shellcheck disable=SC2068
65+
java ${JAVA_OPTS} -jar "$executable" batch ${BATCH_OPTS} --includes-base-dir "${root}" --fail-fast -- ${files[@]} 2>&1 | tee "$tmpfile"
66+
retcode=${PIPESTATUS[0]}
6767
fi
6868

69-
if [[ -n "$GENERATE_ERROR" ]]; then
69+
if [[ $retcode -ne 0 ]] || grep -q -i "exception" "$tmpfile"; then
7070
echo "Found exception(s) when running the generator(s) to update the samples."
7171
exit 1
7272
fi

0 commit comments

Comments
 (0)