Skip to content

Commit

Permalink
add support for overriding NODE_ENV. Closes #505
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Dec 27, 2017
1 parent 9f9d7ce commit 13b3b09
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion platform/lambda/runtime/runtime.go
Expand Up @@ -37,6 +37,10 @@ func WithLogger(l log.Interface) Option {
// Init implementation. // Init implementation.
func (r *Runtime) Init(stage string) error { func (r *Runtime) Init(stage string) error {
os.Setenv("UP_STAGE", stage) os.Setenv("UP_STAGE", stage)
os.Setenv("NODE_ENV", stage)
if s := os.Getenv("NODE_ENV"); s == "" {
os.Setenv("NODE_ENV", stage)
}

return nil return nil
} }

3 comments on commit 13b3b09

@matsilva
Copy link

@matsilva matsilva commented on 13b3b09 Dec 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I am new to go, but if I am reading it correctly this is going to override NODE_ENV with the stage variable? Sorry for dumb questions ¯_(ツ)_/¯... I am just interested in learning go.

@tj
Copy link
Member Author

@tj tj commented on 13b3b09 Dec 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only if it == "" :D the Getenv() will give you an empty string if it's not defined, but I should just do if os.Getenv("NODE_ENV") == "" hahah... no reason for the var

@matsilva
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty string if it's not defined

☝️ that explains a lot. Thanks!

Please sign in to comment.