From bee7628d362dba08415a50232363d33e5487a3c4 Mon Sep 17 00:00:00 2001
From: Ian Thomas <ianthomas23@gmail.com>
Date: Thu, 6 Feb 2025 12:32:16 +0000
Subject: [PATCH] Use jq to merge json files

---
 ci/prepare_playwright.sh                | 9 +++++++--
 ci/typescript/create_vanilla_webpack.sh | 9 +++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/ci/prepare_playwright.sh b/ci/prepare_playwright.sh
index a44cf4b..a8b1d19 100755
--- a/ci/prepare_playwright.sh
+++ b/ci/prepare_playwright.sh
@@ -8,6 +8,12 @@ set -eux
 export TYPE=typescript
 export EXAMPLE=vanilla_webpack
 
+function merge-json() {
+  # merge the second json file into the first.
+  TEMP_FILE=$(mktemp)
+  jq '. * input' $1 $2 > TEMP_FILE && mv TEMP_FILE $1
+}
+
 # 1. Create and build example code in temporary directory
 cd $TYPE && bash ./create_$EXAMPLE.sh && cd ..
 
@@ -61,8 +67,7 @@ cat > temp.json << EOF
   }
 }
 EOF
-npm install --save-dev json-merger
-npx json-merger --output package.json --pretty package.json temp.json
+merge-json package.json temp.json
 rm temp.json
 
 # 5. Copy tests into temp example directory
diff --git a/ci/typescript/create_vanilla_webpack.sh b/ci/typescript/create_vanilla_webpack.sh
index 8fde85c..e62e838 100755
--- a/ci/typescript/create_vanilla_webpack.sh
+++ b/ci/typescript/create_vanilla_webpack.sh
@@ -8,6 +8,12 @@ mkdir -p $OUTPUT_DIRECTORY
 cd $OUTPUT_DIRECTORY
 rm -rf *
 
+function merge-json() {
+  # merge the second json file into the first.
+  TEMP_FILE=$(mktemp)
+  jq '. * input' $1 $2 > TEMP_FILE && mv TEMP_FILE $1
+}
+
 # 1. Create initial package.json (npm project settings)
 npm init --yes
 
@@ -85,8 +91,7 @@ cat > temp.json << EOF
   }
 }
 EOF
-npm install --save-dev json-merger
-npx json-merger --output package.json --pretty package.json temp.json
+merge-json package.json temp.json
 rm temp.json
 
 # 8. Build and run basic example without any BokehJS