Comparing version 0.7.2 to 0.7.3
@@ -78,3 +78,3 @@ /* | ||
winston.info('Updating application ' + existing.name.magenta); | ||
jitsu.apps.update(existing.name, pkg, function (err) { | ||
jitsu.apps.update(jitsu.config.get('username') + '/' + existing.name, pkg, function (err) { | ||
if (err) { | ||
@@ -347,3 +347,2 @@ return callback(err); | ||
apps.update = function (name, callback) { | ||
if(typeof name === 'function') { | ||
@@ -350,0 +349,0 @@ callback = name; |
@@ -18,2 +18,3 @@ /* | ||
'jitsu env list', | ||
'jitsu env list <app>', | ||
'jitsu env set <key> <value>', | ||
@@ -46,7 +47,3 @@ 'jitsu env get <key>', | ||
if(app.name.search('/') === -1){ | ||
app.name = jitsu.config.get('username') + '/' + app.name; | ||
} | ||
jitsu.apps.update(app.name, { env: app.env }, callback); | ||
jitsu.apps.update(jitsu.config.get('username') + '/' + app.name, { env: app.env }, callback); | ||
}); | ||
@@ -129,6 +126,2 @@ }; | ||
} | ||
if(app.name.search('/') === -1){ | ||
app.name = jitsu.config.get('username') + '/' + app.name; | ||
} | ||
@@ -156,4 +149,14 @@ delete app.env[key]; | ||
// | ||
env.list = function (callback) { | ||
viewApp(callback, function (err, app) { | ||
env.list = function (appName, callback) { | ||
if (typeof appName === 'function') { | ||
callback = appName; | ||
appName = null; | ||
viewApp(callback, success); | ||
} | ||
else { | ||
viewAppByName(appName, callback, success); | ||
} | ||
function success(err, app) { | ||
if (!app.env || Object.keys(app.env).length === 0) { | ||
@@ -171,3 +174,3 @@ winston.warn('No environment variables for ' + app.name.magenta); | ||
callback(); | ||
}); | ||
} | ||
}; | ||
@@ -206,3 +209,3 @@ | ||
// Attempts to read the package.json for the current directory | ||
// and retreive it from Nodejitsu. | ||
// and retrieve it from Nodejitsu. | ||
// | ||
@@ -221,1 +224,16 @@ function viewApp (callback, success) { | ||
} | ||
// | ||
// ### @private viewAppByName (appName, callback, success) | ||
// #### @callback {function} Continuation to respond to on error. | ||
// #### @success {function} Continuation to respond to on success. | ||
// Attempts to retrieve the application from Nodejitsu with the given name. | ||
// | ||
function viewAppByName (appName, callback, success) { | ||
if (appName.search('/') === -1) { | ||
appName = jitsu.config.get('username') + '/' + appName; | ||
} | ||
jitsu.apps.view(appName, function (err, app) { | ||
return err ? callback(err) : success(null, app); | ||
}); | ||
} |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "0.7.2", | ||
"version": "0.7.3", | ||
"author": "Nodejitsu Inc. <support@nodejitsu.com>", | ||
@@ -14,0 +14,0 @@ "repository": { |
@@ -19,3 +19,2 @@ /* | ||
runJitsuCommand = helper.runJitsuCommand; | ||
vows.describe('jitsu/commands/env').addBatch({ | ||
@@ -43,2 +42,19 @@ 'This test requires jitsu be unauthorized': function () { | ||
})) | ||
}) | ||
.addBatch({ | ||
'env list foobar': runJitsuCommand( | ||
mockRequest.mock(helper.mockOptions, helper.mockDefaults) | ||
.get('/apps/mickey/foobar') | ||
.respond({ | ||
body: { | ||
app: { | ||
name: 'application', | ||
state: 'stopped', | ||
env: { foo: 'bar', baz: 'buzz' }, | ||
subdomain:'application', | ||
scripts: { start: './server.js' }, | ||
snapshots: [{ filename: 'FILENAME' }] | ||
} | ||
} | ||
})) | ||
}).addBatch({ | ||
@@ -76,3 +92,3 @@ 'env get foo': runJitsuCommand( | ||
}) | ||
.put('/apps/mickey/mickey/application')) | ||
.put('/apps/mickey/application')) | ||
}).addBatch({ | ||
@@ -94,3 +110,3 @@ 'env set delete test': runJitsuCommand( | ||
}) | ||
.put('/apps/mickey/mickey/application')) | ||
.put('/apps/mickey/application')) | ||
}).export(module); |
828949
4683