Add ability to detect running in node-dev (vs standard node) #62

Closed
philion opened this Issue Apr 3, 2013 · 8 comments

Projects

None yet

3 participants

@philion
philion commented Apr 3, 2013

Right now, I've got a check to see if process.env._ ends with 'node.dev' to check if my service is running in node-dev, so it can automatically set some debug flags (like not running on HTTPS only).

It would be great if there was an easier way to detect this, like setting a well-defined, documented flag on process.env.

@fgnass
Owner
fgnass commented Apr 3, 2013

Good idea! Maybe something like process.node_dev instead of an environment variable?

@fgnass fgnass closed this in 67253d6 Apr 6, 2014
@gasi
Collaborator
gasi commented Aug 17, 2015

@fgnass Would it be possible to use a different environment variable than NODE_ENV to denote that one is running within node-dev, e.g. NODE_DEV=true? I ask because we and probably others want to know whether developer explicitly set NODE_ENV=development which is now not possible as node-dev sets it itself.

@fgnass
Owner
fgnass commented Aug 18, 2015

I'm hesitant because I think that coupling one's code to a specific process supervisor (like node-dev) would be a bad practice. But maybe I'm just missing a good use case. Can you elaborate in which situations you would want to perform such a check?

@gasi
Collaborator
gasi commented Aug 18, 2015

@fgnass Agreed, I now realize making it process supervisor specific would be bad. But then why even set NODE_ENV=development inside node-dev? Wouldn’t it be less opinionated to just have developers set environment variables externally, e.g. NODE_ENV=development node-dev app.js? I just checked and it works. The reason I am proposing this is because in our config system we want to distinguish whether the user set NODE_ENV or not, but if node-dev does it, it’s impossible to tell.

Would setting NODE_ENV=development externally work for you @philion?

Feel free to expand on this if I missed anything, @aseemk.

@fgnass
Owner
fgnass commented Aug 18, 2015

+1 for not setting NODE_ENV at all

@gasi
Collaborator
gasi commented Aug 18, 2015

@fgnass Sweet! Now, let’s talk about logistics 😜

Technically, removing setting of NODE_ENV is a breaking change. Have you tried following semver so far which means we should bump it to 3.0.0, or shall we just release it as 2.8.0?

@philion Would it work for you to just set NODE_ENV externally instead of relying on node-dev for it? I’d appreciate your input 😃

@fgnass
Owner
fgnass commented Aug 18, 2015

Yep, versioning has been strictly semantic so far, so this would be 3.0.0.

@gasi
Collaborator
gasi commented Aug 18, 2015

@fgnass Thanks for confirming. I’ll remove the NODE_ENV setting code and publish as 3.0.0, so people like @philion should not be affected 👍

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