From 14d576787a9502aa59a52705ad1808b63f90498e Mon Sep 17 00:00:00 2001 From: Rudolf Thomas Date: Fri, 13 Dec 2024 11:48:19 +0100 Subject: [PATCH] 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. --- acceptance_tests/split-printer.sh | 22 +++++++++++++++++++++- cmd/root.go | 2 +- pkg/yqlib/printer_writer.go | 5 +++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/acceptance_tests/split-printer.sh b/acceptance_tests/split-printer.sh index 4629c4967a3..50554207bb5 100755 --- a/acceptance_tests/split-printer.sh +++ b/acceptance_tests/split-printer.sh @@ -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 \ No newline at end of file +testSplitWithDirectories() { + cat >test.yml <