mirror of
https://github.com/tests-always-included/mo.git
synced 2024-12-18 16:27:52 +00:00
Fix exit code when partial file not found
This commit is contained in:
parent
6376a9b817
commit
078dcabb06
8
mo
8
mo
@ -110,7 +110,7 @@ mo() (
|
||||
done
|
||||
fi
|
||||
|
||||
moGetContent moContent "${files[@]}"
|
||||
moGetContent moContent "${files[@]}" || return 1
|
||||
moParse "$moContent" "" true
|
||||
)
|
||||
|
||||
@ -246,7 +246,7 @@ moGetContent() {
|
||||
content="$content"'{{>'"$filename"'}}'
|
||||
done
|
||||
else
|
||||
moLoadFile content /dev/stdin
|
||||
moLoadFile content /dev/stdin || return 1
|
||||
fi
|
||||
|
||||
local "$target" && moIndirect "$target" "$content"
|
||||
@ -526,7 +526,7 @@ moLoadFile() {
|
||||
# As a future optimization, it would be worth considering removing
|
||||
# cat and replacing this with a read loop.
|
||||
|
||||
content=$(cat -- "$2"; echo '.')
|
||||
content=$(cat -- "$2" && echo '.') || return 1
|
||||
len=$((${#content} - 1))
|
||||
content=${content:0:$len} # Remove last dot
|
||||
|
||||
@ -735,7 +735,7 @@ moPartial() {
|
||||
# but that's difficult when you're only given filenames.
|
||||
cd "$(dirname -- "$moFilename")" || exit 1
|
||||
moUnindented="$(
|
||||
moLoadFile moPartial "${moFilename##*/}"
|
||||
moLoadFile moPartial "${moFilename##*/}" || exit 1
|
||||
moParse "${moPartial}" "$6" true
|
||||
|
||||
# Fix bash handling of subshells and keep trailing whitespace.
|
||||
|
1
tests/partial-missing.expected
Normal file
1
tests/partial-missing.expected
Normal file
@ -0,0 +1 @@
|
||||
cat: partial-missing.partial: No such file or directory
|
8
tests/partial-missing.sh
Executable file
8
tests/partial-missing.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cd "${0%/*}"
|
||||
../mo partial-missing.template 2>&1
|
||||
|
||||
if [[ $? -ne 1 ]]; then
|
||||
echo "Did not return 1"
|
||||
fi
|
1
tests/partial-missing.template
Normal file
1
tests/partial-missing.template
Normal file
@ -0,0 +1 @@
|
||||
Won't be there: {{> partial-missing.partial}}
|
Loading…
Reference in New Issue
Block a user