Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install bin in npm postinstall #14

Open
SpainTrain opened this issue Jan 26, 2024 · 1 comment
Open

Install bin in npm postinstall #14

SpainTrain opened this issue Jan 26, 2024 · 1 comment

Comments

@SpainTrain
Copy link

First - really appreciate this library, it has saved a ton of time in my project!

It appears that the cloudflared binary installation - https://github.com/JacobLinCool/node-cloudflared/blob/b45b5fc06d0066c3fe3aded4cb3524374adf09a0/src/install.ts - to be performed in the postinstall hook - https://github.com/JacobLinCool/node-cloudflared/blob/b45b5fc06d0066c3fe3aded4cb3524374adf09a0/scripts/postinstall.mjs - rather than as a separate step out-of-band.

I am curious:

  • Is there a use case this separation is supporting (I am guessing maybe version selection based on Install specified version of cloudflared #2
  • Would you be open to a PR to use the postinstall hook approach, as long as it also supported any additional use cases the current approach supports?

Cheers!

@JacobLinCool
Copy link
Owner

Hi @SpainTrain.

Is there a use case this separation is supporting (I am guessing maybe version selection based on Install specified version of cloudflared #2

No, the separation is a workaround for the dependency problem during the development setup. When running pnpm i in the development environment, the lib directory has not been transpiled, so directly importing it will cause the installation to fail. That's why scripts/postinstall.mjs needs to run (in the development environment) before installing the cloudflared binary.

Would you be open to a PR to use the postinstall hook approach, as long as it also supported any additional use cases the current approach supports?

Yes, I think it's possible to simplify the postinstall script from node scripts/postinstall.mjs && node lib/cloudflared.js -v to something like node scripts/postinstall.mjs by dynamically importing lib/install.js after the required build process (if in the development environment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants