dominique-mueller / hugo-installer

Installs hugo into your repository.
https://www.npmjs.com/package/hugo-installer
MIT License
21 stars 4 forks source link

Option to only install hugo on npm --production #39

Closed sean-au closed 2 years ago

sean-au commented 3 years ago

My current issue is I have set up my hugo projects so that dependencies which are not required on netlify (e.g. linting or formatting or hugo) are installed as devDependencies. This way my netlify build is sped up.

The problem is that I have hugo-installer set up as a postinstall script and netlify tried to run it, forcing me to have hugo-installer installed as a normal dependency. (netlify is configured to pass the --production parameter)

I have looked into disabling postinstall on production and I cant find a clean solution, without adding another js script to the project.

Would it be easier to include this script in hugo-installer and provide the option e.g. --development so that if hugo-installer is run in the production environment (which only happens if the user specifies this environment) it will exit without running any code.

dominique-mueller commented 3 years ago

I haven't had the chance yet to use Netflity, but I understand that you want to simulate Hugo being a dependency instead of a devDependency, which is something npm doesn't support out of the box for postinstall scripts.

I don't think adding this feature makes sense in the context of hugo-installer, I instead see it as a separate concern that should be handled within the npm script itself.

A quick research brought me to npm packages like if-env or per-env, have you tried using one of those as a solution?

sean-au commented 3 years ago

Thanks Dominique, I will check out those two packages and report back.

On Thu, 29 Jul 2021 at 23:17, Dominique Müller @.***> wrote:

I haven't had the chance yet to use Netflity, but I understand that you want to simulate Hugo being a dependency instead of a devDependency, which is something npm doesn't support out of the box for postinstall scripts.

I don't think that adding this feature makes sense in the context of hugo-installer, I instead see it as a separate concern that should be handled within the npm script itself.

A quick research brought me to npm packages like if-env https://github.com/ericclemmons/if-env or per-env https://github.com/ericclemmons/per-env, have you tried to use on of those as a solution?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dominique-mueller/hugo-installer/issues/39#issuecomment-889135734, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARTWGA6QLWOBDV2K754EX43T2FIGZANCNFSM5BF6CZZA .

dominique-mueller commented 3 years ago

Any luck? :)

sean-au commented 2 years ago

Yes

There is a npm package called if-env which allows you to only run the hugo postinstall on development (Which is the default environment).

On the other hand, only the initial netlify build is slowed down, everything is cached for subsequent builds