Skip to content

Commit

Permalink
[minor] Style changes s/if(/if (/, s/function(/function (/, s/){/) {/
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Feb 5, 2013
1 parent 21e8a5f commit 8aaf6a6
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 98 deletions.
6 changes: 3 additions & 3 deletions lib/jitsu.js
Expand Up @@ -362,10 +362,10 @@ jitsu.showError = function (command, err, shallow, skip) {
}
else {
if (err.stack && !shallow) {
if(err.message && err.message === 'socket hang up'){
if (err.code){
if (err.message && err.message === 'socket hang up') {
if (err.code) {
jitsu.log.info('');
if (err.code === 'ECONNRESET'){
if (err.code === 'ECONNRESET') {
jitsu.log.info(
'jitsu\'s client request timed out before the server ' +
'could respond'
Expand Down
47 changes: 23 additions & 24 deletions lib/jitsu/commands/apps.js
Expand Up @@ -66,32 +66,31 @@ apps.deploy = function (callback) {
//
// Allows arbitrary amount of arguments to deploy
//
if(arguments.length) {
if (arguments.length) {
callback = utile.args(arguments).callback;
}

function promptLogin () {
jitsu.log.warn("No user is logged in");
jitsu.log.warn("Please authenticate");
jitsu.commands.users.login(function (err) {
if (err) {
return callback(err);
}
jitsu.commands.apps.deploy(callback);
});
jitsu.log.warn("No user is logged in");
jitsu.log.warn("Please authenticate");
jitsu.commands.users.login(function (err) {
return err
? callback(err)
: jitsu.commands.apps.deploy(callback);
});
}

//
// If not logged in require the user to authenticate before deploying
//
if (!jitsu.config.get('username') && !jitsu.config.get('password')) {
return promptLogin();
return promptLogin();
}

//
// Allows arbitrary amount of arguments to deploy
//
if(arguments) {
if (arguments) {
arguments = Array.prototype.slice.call(arguments);
callback = arguments[arguments.length - 1];
}
Expand Down Expand Up @@ -257,7 +256,7 @@ apps.create = function (target, callback) {
//
// Allows arbitrary amount of arguments to deploy
//
if(arguments.length) {
if (arguments.length) {
callback = utile.args(arguments).callback;
}

Expand Down Expand Up @@ -316,7 +315,7 @@ apps.list = function (username, callback) {

var authuser = jitsu.config.get('username') || '';

if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
username = args[0] || authuser;
Expand Down Expand Up @@ -374,7 +373,7 @@ apps.list = function (username, callback) {
// Remark: Attempt to always show running snapshot
//
var snapshot = '---';
if(app.running && app.running.filename) {
if (app.running && app.running.filename) {
snapshot = app.running.filename;
}

Expand Down Expand Up @@ -414,7 +413,7 @@ apps.view = function (name, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
name = args[0] || null;
Expand Down Expand Up @@ -449,8 +448,8 @@ apps.view = function (name, callback) {

if (!name) {
getAppName(function (err, pkg) {
if(err) {
jitsu.commands.list(function(){
if (err) {
jitsu.commands.list(function () {
jitsu.log.info('Which ' + 'app'.magenta + ' to view?');
jitsu.prompt.get(["app name"], function (err, result) {
if (err) {
Expand Down Expand Up @@ -493,7 +492,7 @@ apps.update = function (name, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
name = args[0] || null;
Expand Down Expand Up @@ -546,7 +545,7 @@ apps.destroy = function (name, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
name = args[0] || null;
Expand All @@ -564,7 +563,7 @@ apps.destroy = function (name, callback) {
jitsu.package.tryRead(process.cwd(), callback, function (pkg) {
jitsu.log.info('Attempting to destroy app ' + pkg.name.magenta);
name = pkg.name;
jitsu.prompt.confirm('yes/no', function(err, result){
jitsu.prompt.confirm('yes/no', function (err, result) {
if (result) {
executeDestroy();
} else {
Expand Down Expand Up @@ -602,7 +601,7 @@ apps.start = function (name, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
name = args[0] || null;
Expand Down Expand Up @@ -662,7 +661,7 @@ apps.restart = function (name, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
name = args[0] || null;
Expand Down Expand Up @@ -713,7 +712,7 @@ apps.stop = function (name, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
name = args[0] || null;
Expand All @@ -727,7 +726,7 @@ apps.stop = function (name, callback) {
// TODO: replace this error handling with errs library
//
if (err) {
if(err.result && err.result.error === "not_found") {
if (err.result && err.result.error === "not_found") {
jitsu.log.error('App ' + name.magenta + ' doesn\'t exist on Nodejitsu yet!');
return callback({});
}
Expand Down
18 changes: 9 additions & 9 deletions lib/jitsu/commands/databases.js
Expand Up @@ -60,7 +60,7 @@ databases.create = function (requestedDatabaseType, requestedDatabaseName, callb
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
requestedDatabaseType = args[0] || null;
Expand Down Expand Up @@ -118,28 +118,28 @@ databases.create = function (requestedDatabaseType, requestedDatabaseName, callb

var funcs = [
function getDBName(cb) {
if(database.name) {
if (database.name) {
return cb();
}

jitsu.log.error('Database name is required');
jitsu.prompt.get({
name: 'database name',
default: database.type
}, function(e, res) {
}, function (e, res) {
database.name = res['database name'] || database.name;
cb();
});
},

function getDBType(cb) {
if(database.type) {
if (database.type) {
return cb();
}

jitsu.log.warn('Valid database types are: ' + 'couch'.magenta + ' (iriscouch), ' + 'redis'.magenta + ' (irisredis), '
+ 'mongo'.magenta + ' (mongolab), ' + 'mongohq'.magenta + ', or' + 'redistogo'.magenta);
jitsu.prompt.get('database type', function(e, res) {
jitsu.prompt.get('database type', function (e, res) {
database.type = res['database type'] || database.type;
cb();
});
Expand All @@ -150,7 +150,7 @@ databases.create = function (requestedDatabaseType, requestedDatabaseName, callb
(function iterate(keys) {
var elem = funcs[--keys];

if(!elem) {
if (!elem) {
return createDatabase(database, callback);
}

Expand Down Expand Up @@ -179,7 +179,7 @@ databases.get = function (databaseName, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
databaseName = args[0] || null;
Expand Down Expand Up @@ -220,7 +220,7 @@ databases.list = function (username, callback) {
//
// Allows arbitrary amount of arguments to deploy
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
username = args[0] || null;
Expand Down Expand Up @@ -263,7 +263,7 @@ databases.destroy = function (databaseName, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
databaseName = args[0] || null;
Expand Down
22 changes: 11 additions & 11 deletions lib/jitsu/commands/env.js
Expand Up @@ -37,7 +37,7 @@ env.set = function (appName, key, value, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
appName = args[0] || null;
Expand Down Expand Up @@ -89,7 +89,7 @@ env.get = function (appName, key, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
appName = args[0] || null;
Expand Down Expand Up @@ -135,7 +135,7 @@ env.delete = function (appName, key, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
appName = args[0] || null;
Expand Down Expand Up @@ -180,7 +180,7 @@ env.list = function (appName, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
appName = args[0] || null;
Expand Down Expand Up @@ -226,7 +226,7 @@ env.clear = function (appName, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
appName = args[0] || null;
Expand Down Expand Up @@ -263,15 +263,15 @@ env.save = function (appName, file, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
appName = args[0] || null;
file = args[1] || 'env.json';
if (appName === null){
if (appName === null) {
viewApp(callback, executeSave);
} else{
viewAppByName(appName, function(){jitsu.commands.env.save(null, appName, callback);}, executeSave);
viewAppByName(appName, function () {jitsu.commands.env.save(null, appName, callback);}, executeSave);
}
}

Expand Down Expand Up @@ -325,15 +325,15 @@ env.load = function (appName, file, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
appName = args[0] || null;
file = args[1] || 'env.json';
if (appName === null){
if (appName === null) {
viewApp(callback, executeLoad);
} else{
viewAppByName(appName, function(){jitsu.commands.env.load(null, appName, callback);}, executeLoad);
viewAppByName(appName, function () {jitsu.commands.env.load(null, appName, callback);}, executeLoad);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/jitsu/commands/install.js
Expand Up @@ -62,7 +62,7 @@ module.exports = function (requestedApp, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
requestedApp = args[0] || null;
Expand Down
8 changes: 4 additions & 4 deletions lib/jitsu/commands/logs.js
Expand Up @@ -30,7 +30,7 @@ logs.all = function (amount, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
amount = args[0] || null;
Expand Down Expand Up @@ -95,7 +95,7 @@ logs.app = function (appName, amount, callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
appName = args[0] || null;
Expand Down Expand Up @@ -129,7 +129,7 @@ logs.app = function (appName, amount, callback) {
if (!appName) {
getAppName(function (err, name) {
if (err) {
jitsu.commands.list(function(){
jitsu.commands.list(function () {
jitsu.log.info('Which application to view ' + 'logs'.magenta + ' for?');
jitsu.prompt.get(["app name"], function (err, result) {
if (err) {
Expand Down Expand Up @@ -171,7 +171,7 @@ function putLogs (results, appName, amount, showApp) { //TODO: utilize amount an
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
var args = utile.args(arguments);
results = args[0] || null;
appName = args[1] || null;
Expand Down
2 changes: 1 addition & 1 deletion lib/jitsu/commands/package.js
Expand Up @@ -27,7 +27,7 @@ package.create = function (callback) {
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
if (arguments.length) {
callback = utile.args(arguments).callback;
}

Expand Down

0 comments on commit 8aaf6a6

Please sign in to comment.