Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

Commit

Permalink
Merge pull request #5 from netlify/set-site-env-locally
Browse files Browse the repository at this point in the history
Set site environment variables in local dev
  • Loading branch information
biilmann authored Mar 8, 2019
2 parents 8f6c6d4 + 568d5db commit bf402c6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/commands/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,21 @@ class DevCommand extends Command {
addon.slug
}`
for (const key in addon.env) {
process.env[key] = addon.env[key]
process.env[key] = process.env[key] || addon.env[key]
}
})
const api = this.netlify.api
const apiSite = await api.getSite({site_id: site.id})
// TODO: We should move the environment outside of build settings and possibly have a
// `/api/v1/sites/:site_id/environment` endpoint for it that we can also gate access to
// In the future and that we could make context dependend
if (apiSite.build_settings && apiSite.build_settings.env) {
for (const key in apiSite.build_settings.env) {
process.env[key] = process.env[key] || apiSite.build_settings.env[key]
}
}
}
process.env.NETLIFY_DEV = 'true'
let settings = serverSettings()
if (!(settings && settings.cmd)) {
this.log('No dev server detected, using simple static server')
Expand Down

0 comments on commit bf402c6

Please sign in to comment.