From 0de8609e6ad6c33442a022c0b0b758fef39f683a Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Wed, 4 Feb 2026 23:46:54 +0700 Subject: [PATCH] Fix postinstall patches for partial workspace installs --- package.json | 2 +- scripts/postinstall-patches.mjs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 scripts/postinstall-patches.mjs diff --git a/package.json b/package.json index da543df2b..499ee65c1 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "dev:server": "NODE_ENV=development tsx packages/server/scripts/dev-runner.ts", "dev:app": "npm run start --workspace=@paseo/app", "dev:website": "npm run dev --workspace=@paseo/website", - "postinstall": "patch-package", + "postinstall": "node scripts/postinstall-patches.mjs", "build": "npm run build --workspaces --if-present", "typecheck": "npm run typecheck --workspaces --if-present", "test": "npm run test --workspaces --if-present", diff --git a/scripts/postinstall-patches.mjs b/scripts/postinstall-patches.mjs new file mode 100644 index 000000000..ea0caeea3 --- /dev/null +++ b/scripts/postinstall-patches.mjs @@ -0,0 +1,14 @@ +import { existsSync } from "node:fs"; +import { spawnSync } from "node:child_process"; + +// In CI we often install a single workspace (e.g. server/relay/website). Only apply patches +// when the patched dependency is actually present. +const hasDraggableFlatlist = existsSync("node_modules/react-native-draggable-flatlist"); +if (!hasDraggableFlatlist) { + process.exit(0); +} + +const cmd = process.platform === "win32" ? "patch-package.cmd" : "patch-package"; +const result = spawnSync(cmd, { stdio: "inherit" }); +process.exit(result.status ?? 1); +