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
* 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) ->
remoteAppEnvs = {}
remoteApps = _.map remoteApps, (app) ->
env =
RESIN_DEVICE_UUID: uuid
RESIN: '1'
USER: 'root'
if app.environment_variable?
_.extend(env, app.environment_variable)
env = utils.extendEnvVars(app.environment_variable, uuid)
remoteAppEnvs[app.id] = env
env = _.omit(env, _.keys(specialActionEnvVars))
return {

View File

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

View File

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