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

Propagate NODE_ENV to other packages #58

Merged
merged 1 commit into from
Dec 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/serve.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Ensure that the loaded files and packages have the correct env
process.env.NODE_ENV = process.env.NODE_ENV || 'development'

// Packages
const getPort = require('get-port')
const serve = require('micro/lib')
Expand All @@ -8,16 +11,15 @@ const listening = require('./listening')
const log = require('./log')

module.exports = async (file, flags, restarting) => {
// Ensure that the loaded files have the correct env
process.env.NODE_ENV = process.env.NODE_ENV || 'development'

// Emit SIGNUSR2 to signal restart to user code
if (restarting) {
process.emit('SIGNUSR2')
}

// And then load the files
const module = flags.silent ? getModule(file) : log(getModule(file), flags.limit)
const module = flags.silent
? getModule(file)
: log(getModule(file), flags.limit)
const server = serve(module)

// `3000` is the default port
Expand Down