mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-14 13:22:37 +00:00
Fix compact web sheet swipe crashes
This commit is contained in:
@@ -1,18 +1,56 @@
|
||||
import { existsSync } from "node:fs";
|
||||
import { copyFileSync, existsSync, mkdirSync, readdirSync, rmSync } from "node:fs";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { join } from "node:path";
|
||||
|
||||
// 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) {
|
||||
const patchedPackages = [
|
||||
{
|
||||
nodeModulesPath: "node_modules/react-native-draggable-flatlist",
|
||||
patchPrefix: "react-native-draggable-flatlist+",
|
||||
},
|
||||
{
|
||||
nodeModulesPath: "node_modules/react-native-gesture-handler",
|
||||
patchPrefix: "react-native-gesture-handler+",
|
||||
},
|
||||
];
|
||||
|
||||
const installedPatchPrefixes = patchedPackages
|
||||
.filter(({ nodeModulesPath }) => existsSync(nodeModulesPath))
|
||||
.map(({ patchPrefix }) => patchPrefix);
|
||||
|
||||
if (!existsSync("patches") || installedPatchPrefixes.length === 0) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const patchFilesToApply = readdirSync("patches").filter(
|
||||
(file) =>
|
||||
file.endsWith(".patch") &&
|
||||
installedPatchPrefixes.some((patchPrefix) => file.startsWith(patchPrefix)),
|
||||
);
|
||||
|
||||
if (patchFilesToApply.length === 0) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const isWindows = process.platform === "win32";
|
||||
const cmd = isWindows ? "patch-package.cmd" : "patch-package";
|
||||
const result = spawnSync(cmd, [], {
|
||||
shell: isWindows,
|
||||
stdio: "inherit",
|
||||
windowsHide: true,
|
||||
});
|
||||
const tempPatchDir = join(".tmp", `postinstall-patches-${process.pid}`);
|
||||
|
||||
mkdirSync(tempPatchDir, { recursive: true });
|
||||
for (const patchFile of patchFilesToApply) {
|
||||
copyFileSync(join("patches", patchFile), join(tempPatchDir, patchFile));
|
||||
}
|
||||
|
||||
let result;
|
||||
try {
|
||||
result = spawnSync(cmd, ["--patch-dir", tempPatchDir], {
|
||||
shell: isWindows,
|
||||
stdio: "inherit",
|
||||
windowsHide: true,
|
||||
});
|
||||
} finally {
|
||||
rmSync(tempPatchDir, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
process.exit(result.status ?? 1);
|
||||
|
||||
Reference in New Issue
Block a user