mirror of
https://github.com/mikefarah/yq.git
synced 2026-08-24 08:22:13 +08:00
feat: Create parent directories if --split-exp is used.
Problem: When --split-exp is used and produces filenames with slashes in them, the target directories must already exist otherwise yq fails. Fix/feature: Create the necessary directories with os.MkdirAll(). The permissions 0750 were chosen to satisfy the vulnerability checker.
This commit is contained in:
committed by
Mike Farah
parent
294a1709ad
commit
f73c862cc5
@@ -2,6 +2,7 @@
|
||||
|
||||
setUp() {
|
||||
rm test*.yml || true
|
||||
rm -rf test_dir* || true
|
||||
}
|
||||
|
||||
testBasicSplitWithName() {
|
||||
@@ -204,4 +205,23 @@ EOM
|
||||
assertEquals "$expectedDoc3" "$doc3"
|
||||
}
|
||||
|
||||
source ./scripts/shunit2
|
||||
testSplitWithDirectories() {
|
||||
cat >test.yml <<EOL
|
||||
f: test_dir1/file1
|
||||
---
|
||||
f: test_dir2/dir22/file2
|
||||
---
|
||||
f: file3
|
||||
EOL
|
||||
|
||||
./yq e --no-doc -s ".f" test.yml
|
||||
|
||||
doc1=$(cat test_dir1/file1.yml)
|
||||
assertEquals "f: test_dir1/file1" "$doc1"
|
||||
doc2=$(cat test_dir2/dir22/file2.yml)
|
||||
assertEquals "f: test_dir2/dir22/file2" "$doc2"
|
||||
doc3=$(cat file3.yml)
|
||||
assertEquals "f: file3" "$doc3"
|
||||
}
|
||||
|
||||
source ./scripts/shunit2
|
||||
|
||||
Reference in New Issue
Block a user