Skip to content

Commit

Permalink
Merge pull request #242 from nodejitsu/gh-241
Browse files Browse the repository at this point in the history
[fix] issue #241 (jitsu env set would set null: null)
  • Loading branch information
indexzero committed Jul 10, 2012
2 parents 19c93ea + 57f7d4b commit 7fb440b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/jitsu/commands/env.js
Expand Up @@ -30,7 +30,15 @@ env.usage = [
// the application in the current directory.
//
env.set = function (appName, key, value, callback) {

if (value === null) {
if (key === null) {
jitsu.log.error(
'You must specify both an environment variable name and value.'
);
return callback({});
}

value = key;
key = appName;
return viewApp(callback, update);
Expand All @@ -39,6 +47,7 @@ env.set = function (appName, key, value, callback) {
viewAppByName(appName, callback, update);

function update(err, app) {

app.env = app.env || {};
app.env[key] = value;
jitsu.apps.update(app.name, { env: app.env }, callback);
Expand Down
8 changes: 8 additions & 0 deletions test/commands/env-test.js
Expand Up @@ -134,6 +134,14 @@ vows.describe('jitsu/commands/env').addBatch({
}
}, { 'x-powered-by': 'Nodejitsu' })
})
}).addBatch({
'env set': shouldNodejitsuOk(
'Should exit with an error',
function assertion (ign, err) {
err = ign;
assert.isTrue(!!err);
}
)
}).addBatch({
'env set test truthy': shouldNodejitsuOk(function setup() {
nock('http://api.mockjitsu.com')
Expand Down

0 comments on commit 7fb440b

Please sign in to comment.