2015-06-18 06:58:58 +08:00
|
|
|
Actions = require './onboarding-actions'
|
|
|
|
NylasStore = require 'nylas-store'
|
|
|
|
|
|
|
|
class NylasApiEnvironmentStore extends NylasStore
|
|
|
|
constructor: ->
|
|
|
|
@listenTo Actions.changeAPIEnvironment, @_setEnvironment
|
|
|
|
|
|
|
|
defaultEnv = if atom.inDevMode() then 'staging' else 'staging'
|
|
|
|
@_setEnvironment(defaultEnv) unless atom.config.get('env')
|
|
|
|
|
|
|
|
getEnvironment: -> atom.config.get('env')
|
|
|
|
|
|
|
|
_setEnvironment: (env) ->
|
2015-07-09 04:25:11 +08:00
|
|
|
throw new Error("Environment #{env} is not allowed") unless env in ['development', 'experimental', 'staging', 'production']
|
2015-06-18 06:58:58 +08:00
|
|
|
atom.config.set('env', env)
|
|
|
|
@trigger()
|
|
|
|
|
|
|
|
module.exports = new NylasApiEnvironmentStore()
|