diff --git a/patches/patch.js b/patches/patch.js index c2f5f27a..bbb278d7 100644 --- a/patches/patch.js +++ b/patches/patch.js @@ -4,6 +4,16 @@ * The intention here is to only run `patch-package` during local installation, IE. during * development of the library and not upon installation by the users of the library. */ -if (process.cwd() === process.env.INIT_CWD) { - require("patch-package"); + +// Check if the script is running within node_modules +const isInNodeModules = __dirname.includes('node_modules'); + +// Check if the script is running in a workspace (e.g., pnpm, yarn workspaces) +const isInWorkspace = process.env.PWD && process.env.PWD.includes('node_modules'); + +// Determine if we should run patch-package +const shouldRunPatchPackage = !isInNodeModules && !isInWorkspace; + +if (shouldRunPatchPackage) { + require('patch-package'); }