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

Disabling hooks via env variables #3618

Closed
Mudrekh opened this issue Feb 29, 2016 · 4 comments
Closed

Disabling hooks via env variables #3618

Mudrekh opened this issue Feb 29, 2016 · 4 comments

Comments

@Mudrekh
Copy link

Mudrekh commented Feb 29, 2016

While trying to start our sails app in different ways, I encountered this error while trying to disable hooks (specifically grunt) by setting an environment variable.

Using 'sails_hooks__grunt=false sails lift' causes this to be thrown

error: Malformed hook! (grunt)
error: Hooks should be a function with one argument (sails)

Looking a little deeper, it seems like process.env variables are restricted to strings, but ./lib/app/private/loadHooks.js is specifically looking for Boolean literals.

@Mudrekh
Copy link
Author

Mudrekh commented Feb 29, 2016

@zivc Adding a semicolon doesn't seem to do anything, running 'sails_hooks__grunt=false; sails lift --verbose' still has grunt output.

Just for extra clarification, I am running this directly using the cli by setting the environment variable in line.

@mananjadhav
Copy link

Not sure if it'll work but can you try setting it as 0?

sails_hooks__grunt=0 sails lift ?

As you rightly said process.env are defaulted as strings only.

@sgress454
Copy link
Member

@Mudrekh alas, that's environment variables for you. I can patch this for hooks, because it'd be handy to be able to turn them off via environment configs, but there's no general fix we can make here because a) we use another module (rc) to load env vars into config, and b) there's no hard-and-fast rules about what configs can take what types.

@Mudrekh
Copy link
Author

Mudrekh commented Feb 29, 2016

@Mananj That would also be passed as a string, so even if you did a truthy test on it, it wouldn't pass hook loading in loadHooks..js

@sgress454 That seems reasonable. A patch would definitely be better than nothing. I assume something simple like just adding hookPrototype === 'false' in loadHooks.js at line 22?

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

No branches or pull requests

3 participants