Permalink
Browse files

[refactor] JSHint support with code passing (a.k.a valid js)

  • Loading branch information...
1 parent 2c482aa commit feeb80fd953ed4db76a2c7ff811f1eecabce78cc @alejandro alejandro committed Jun 26, 2012
Showing with 220 additions and 162 deletions.
  1. +1 −1 lib/app.js
  2. +2 −2 lib/appdomain.js
  3. +19 −16 lib/apps.js
  4. +24 −21 lib/commands.js
  5. +80 −72 lib/config.js
  6. +13 −6 lib/coupon.js
  7. +26 −16 lib/env.js
  8. +20 −11 lib/log.js
  9. +24 −10 lib/npm.js
  10. +11 −7 lib/user.js
View
@@ -145,7 +145,7 @@ function init (args) {
'\n(2) You just want to setup your existent app?\n'+'note:'.italic +
' if you choose 2 be sure that you are into your app\'s dir\n'.bold;
- read({ prompt: question, default: 1}, function(err,res) {
+ read({ prompt: question, 'default': 1}, function(err,res) {
var isNewRep = false;
View
@@ -129,9 +129,9 @@ function remove (args) {
log.warn(original);
}
});
- setTimeout(function(){
+ setTimeout(function () {
log.error('No response');
- },1000*10)
+ }, 1000*10);
}
function list () {
View
@@ -3,29 +3,24 @@
* A CLI tool to allow interaction with the http://nodester.com/ platform.
* @division apps
*/
+/*jshint node:true, noempty:true, laxcomma:true, laxbreak:false */
+
+"use strict";
var Node = require('nodester-api').nodester
, config = require('./config')
, log = require('./log')
;
-
-var Apps = module.exports;
-
-Apps.usage = function () {
+function usage () {
log.usage('apps list - list all your registered apps (shortcut for `' + config.brand + ' app list`)');
log.info('ok!'.green.bold);
}
-Apps.run = function () {
- //Placeholder for later adding more `cmd apps` commands
- this.list();
-}
-
-Apps.list = function (args) {
- config.check()
- log.info('Listing ' + config.username + '\'s apps.')
- log.info('Waiting for the response...')
+function list (args) {
+ config.check();
+ log.info('Listing ' + config.username + '\'s apps.');
+ log.info('Waiting for the response...');
config.check();
var nodeapi = new Node(config.username, config.password, config.apihost, config.apisecure);
nodeapi.apps_list(function (err, data, original) {
@@ -38,11 +33,11 @@ Apps.list = function (args) {
r = data[i].running;
var state = false;
if (data[i].running.hasOwnProperty('indexOf') && (data[i].running.indexOf('error') >-1|| data[i].running.indexOf('failed-to') > -1))
- var state = true;
- if (data[i].running == false || data[i].running == 'false' || state) {
+ state = true;
+ if (data[i].running === false || data[i].running == 'false' || state) {
l = 'warn';
if (r === false || r == 'false') {
- r = 'false'
+ r = 'false';
}
r = r.red;
}
@@ -54,3 +49,11 @@ Apps.list = function (args) {
}
});
}
+
+var Apps = {
+ usage: usage,
+ run: list,
+ list: list
+};
+
+module.exports = Apps;
View
@@ -3,6 +3,9 @@
* A CLI tool to allow interaction with the http://nodester.com/ platform.
* @division commands
*/
+/*jshint node:true, noempty:true, laxcomma:true, laxbreak:false */
+
+"use strict";
var fs = require('fs')
, path = require('path')
@@ -83,16 +86,16 @@ var commands = {
},
authors: {
usage: function(){
- log.plain('\033[33m\033[1m \n'+
- ' _ _ \n'+
- ' _ __ ___ __| | ___ ___| |_ ___ _ __ \n'+
- " | '_ \\ / _ \\ / _ |/ _ \\ __| __/ _ \\ '__| \n"+
- ' | | | | (_) | (_| | __\\__ \\ |_ __/ | \n'+
- ' |_| |_|\\___/ \\__,_|\\___|___/\\__\\___|_| \033[22m\033[39m\n'+
- '\n'+
- ' \033[1mOpen Source Node.js Hosting Platform.\033[22m\n'+
+ log.plain(["",
+ ' _ _ ',
+ ' _ __ ___ __| | ___ ___| |_ ___ _ __ ',
+ " | '_ \\ / _ \\ / _ |/ _ \\ __| __/ _ \\ '__| ",
+ ' | | | | (_) | (_| | __\\__ \\ |_ __/ | ',
+ ' |_| |_|\\___/ \\__,_|\\___|___/\\__\\___|_| '].join('\n').bold.yellow+
+ '\n\n'+
+ ' Open Source Node.js Hosting Platform. \n'.bold.white+
' http://github.com/nodester"\n');
- log.plain(' * ' + pack.author)
+ log.plain(' * ' + pack.author);
pack.contributors.sort().forEach(function(author){
log.plain(' * ' + author.toString());
});
@@ -109,6 +112,14 @@ for (var key in versions){
}
function run (cmds, command) {
+ function tail (args){
+ if(log.inTest){
+ // mocha args
+ args.pop();
+ args.pop();
+ }
+ return args;
+ }
if (!command) {
showHelp(commands);
@@ -121,15 +132,7 @@ function run (cmds, command) {
}
if (cmds[command]) {
- function tail (args){
- if(log.inTest){
- // mocha args
- args.pop();
- args.pop();
- }
- return args;
- }
if (cmds[command][process.argv.slice(1)[0]]) {
cmds[command][process.argv.slice(1)[0]](tail(process.argv.slice(2)));
} else if (cmds[command].run) {
@@ -143,12 +146,12 @@ function run (cmds, command) {
log.info(command, 'usage:');
cmds[command] && cmds[command].usage && cmds[command].usage();
} else {
- log.info('Dieing cleanly')
+ log.info('Dieing cleanly');
}
}
} else {
log.warn('Run > nodester '+ command + ' usage ');
- log.error('command not found: ' + args);
+ log.error('command not found: ' + command);
}
}
@@ -176,11 +179,11 @@ function showUsage () {
cmds[i].usage();
}
}
-};
+}
module.exports = {
commands : commands,
run : run,
showHelp : showHelp,
log : log
-}
+};
Oops, something went wrong.

0 comments on commit feeb80f

Please sign in to comment.