cypress-cucumber-preprocessor icon indicating copy to clipboard operation
cypress-cucumber-preprocessor copied to clipboard

fix: prevent postinstall script from running when installed as dependency using pnpm

Open sternma opened this issue 1 year ago • 4 comments

The postinstall script runs patch-package even when the package is installed as a dependency, causing installation failures for users who don't have patch-package installed in their projects. This issue is particularly evident when using pnpm, which handles module isolation more strictly.

Problem: The postinstall script attempts to run patch-package, which isn't available in user projects, causing installation to fail. The workaround is for the user to add patch-package as a top-level dev-dependency in their own project.

Solution: This fix updates patches/patch.js to check if the script is running inside a node_modules directory. If it is, the script assumes it's being installed as a dependency and skips running patch-package.

Compatibility: Tested with npm, pnpm, and yarn. The fix works across all package managers.

Testing:

  • Verified that postinstall runs during local development.
  • Confirmed that installation succeeds without errors in a test project.

sternma avatar Nov 04 '24 22:11 sternma

Hey @badeball - I read your proposal in cucumber's repo. Would you still consider completing this PR to unblock pnpm users?

sternma avatar Nov 08 '24 04:11 sternma

Would you still consider completing this PR to unblock pnpm users?

This would at the very least have to test the mentioned package managers. Preferably using a different jobs to test latest version of each, using one of the examples.

badeball avatar Nov 09 '24 16:11 badeball

I'm also not a fan of the heuristics implemented here. You're removing the possibility of working inside a node_modules directory. While I don't do this myself, I see no reason for why this library should not allow it.

Edit: Scratch this - as this will exclusively affect developers of the library, ie. me only.

badeball avatar Nov 09 '24 17:11 badeball

I tried using pnpm to install dependencies of one of the examples (esbuild-cjs) and it runs seemingly fine and without errors. What issue have you observed?

badeball avatar Nov 14 '24 14:11 badeball