This is an automated email from the ASF dual-hosted git repository.

apurtell pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/phoenix-site.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new 2a862f21 PHOENIX-7981 Site build improvements (#38)
2a862f21 is described below

commit 2a862f2190682ac3e890e536c577ab3791326f59
Author: Andrew Purtell <[email protected]>
AuthorDate: Tue Aug 4 17:19:27 2026 -0700

    PHOENIX-7981 Site build improvements (#38)
---
 build.sh            | 10 ++++++++--
 unit-tests/setup.ts | 24 ++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/build.sh b/build.sh
index 6302c99b..4afb8325 100755
--- a/build.sh
+++ b/build.sh
@@ -31,10 +31,16 @@ install_node() {
 if ! command -v node > /dev/null 2>&1 || ! command -v npm > /dev/null 2>&1; 
then
   echo "node/npm not found — bootstrapping via nvm..."
   install_node
-elif [ -f "$NVM_DIR/nvm.sh" ]; then
+else
+  NODE_MAJOR="$(node --version | cut -d. -f1 | tr -d v)"
+  if [ "$NODE_MAJOR" -ne "$REQUIRED_NODE_MAJOR" ]; then
+    echo "Node.js ${REQUIRED_NODE_MAJOR} is required (found $(node --version)) 
— bootstrapping via nvm..."
+    install_node
+  elif [ -f "$NVM_DIR/nvm.sh" ]; then
   # nvm is present but may not be sourced in this shell
   # shellcheck source=/dev/null
-  . "$NVM_DIR/nvm.sh"
+    . "$NVM_DIR/nvm.sh"
+  fi
 fi
 
 echo "node $(node --version), npm $(npm --version) -- OK"
diff --git a/unit-tests/setup.ts b/unit-tests/setup.ts
index 0be244d6..70f0c789 100644
--- a/unit-tests/setup.ts
+++ b/unit-tests/setup.ts
@@ -20,6 +20,30 @@ import "@testing-library/jest-dom";
 import { cleanup } from "@testing-library/react";
 import { afterEach } from "vitest";
 
+if (!globalThis.localStorage) {
+  const values = new Map<string, string>();
+  const localStorage: Storage = {
+    get length() {
+      return values.size;
+    },
+    clear: () => {
+      values.clear();
+    },
+    getItem: (key) => values.get(key) ?? null,
+    key: (index) => [...values.keys()][index] ?? null,
+    removeItem: (key) => {
+      values.delete(key);
+    },
+    setItem: (key, value) => {
+      values.set(key, String(value));
+    }
+
+  Object.defineProperty(globalThis, "localStorage", {
+    configurable: true,
+    value: localStorage
+  });
+}
+
 afterEach(() => {
   cleanup();
 });

Reply via email to