Use a function in utils to extend env vars

This commit is contained in:
Pablo Carranza Vélez 2015-10-01 18:18:35 +00:00
parent 65df89aab6
commit 8da8092104
4 changed files with 13 additions and 13 deletions

View File

@ -1,3 +1,5 @@
* Fix preloaded apps so that they have the complete environment [Pablo]
# v0.0.17 # v0.0.17
* Updated bases image to board-specific, and all node versions to 0.10.40-slim [Pablo] * Updated bases image to board-specific, and all node versions to 0.10.40-slim [Pablo]

View File

@ -354,13 +354,7 @@ application.update = update = (force) ->
.then (remoteApps) -> .then (remoteApps) ->
remoteAppEnvs = {} remoteAppEnvs = {}
remoteApps = _.map remoteApps, (app) -> remoteApps = _.map remoteApps, (app) ->
env = env = utils.extendEnvVars(app.environment_variable, uuid)
RESIN_DEVICE_UUID: uuid
RESIN: '1'
USER: 'root'
if app.environment_variable?
_.extend(env, app.environment_variable)
remoteAppEnvs[app.id] = env remoteAppEnvs[app.id] = env
env = _.omit(env, _.keys(specialActionEnvVars)) env = _.omit(env, _.keys(specialActionEnvVars))
return { return {

View File

@ -22,12 +22,7 @@ loadPreloadedApps = ->
fs.readFileAsync(appsPath, 'utf8') fs.readFileAsync(appsPath, 'utf8')
.then(JSON.parse) .then(JSON.parse)
.map (app) -> .map (app) ->
env = app.env = JSON.stringify(utils.extendEnvVars(app.env, userConfig.uuid))
RESIN_DEVICE_UUID: userConfig.uuid
RESIN: '1'
USER: 'root'
_.extend(app.env, env)
app.env = JSON.stringify(app.env)
knex('app').insert(app) knex('app').insert(app)
.catch (err) -> .catch (err) ->
utils.mixpanelTrack('Loading preloaded apps failed', {error: err}) utils.mixpanelTrack('Loading preloaded apps failed', {error: err})

View File

@ -96,3 +96,12 @@ exports.connectivityCheck = _.once ->
else else
console.log('Waiting for connectivity...') console.log('Waiting for connectivity...')
blink.pattern.start(networkPattern) blink.pattern.start(networkPattern)
exports.extendEnvVars = (env, uuid) ->
newEnv =
RESIN_DEVICE_UUID: uuid
RESIN: '1'
USER: 'root'
if env?
_.extend(newEnv, env)
return newEnv