mirror of
https://gitee.com/mirrors_adrian-thurston/yq.git
synced 2026-01-15 07:53:35 +08:00
Remember comments in empty files
This commit is contained in:
@@ -150,6 +150,33 @@ if [[ $X != $expected ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Test: handle empty files with just comments"
|
||||
echo "# comment" > temp.yaml
|
||||
read -r -d '' expected << EOM
|
||||
# comment
|
||||
apple: tree
|
||||
EOM
|
||||
|
||||
./yq e '.apple = "tree"' temp.yaml -i
|
||||
X=$(cat temp.yaml)
|
||||
rm temp.yaml
|
||||
if [[ $X != $expected ]]; then
|
||||
echo "Write empty doc"
|
||||
echo "Expected $expected but was $X"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "# comment" > temp.yaml
|
||||
|
||||
./yq ea '.apple = "tree"' temp.yaml -i
|
||||
X=$(cat temp.yaml)
|
||||
rm temp.yaml
|
||||
if [[ $X != $expected ]]; then
|
||||
echo "Write all empty doc"
|
||||
echo "Expected $expected but was $X"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "--success"
|
||||
|
||||
set -e
|
||||
|
||||
Reference in New Issue
Block a user