Skip to content

Commit

Permalink
[refactor] JSHint support with code passing (a.k.a valid js)
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandro committed Jun 26, 2012
1 parent 2c482aa commit feeb80f
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 162 deletions.
2 changes: 1 addition & 1 deletion lib/app.js
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions lib/appdomain.js
Expand Up @@ -129,9 +129,9 @@ function remove (args) {
log.warn(original);
}
});
setTimeout(function(){
setTimeout(function () {
log.error('No response');
},1000*10)
}, 1000*10);
}

function list () {
Expand Down
35 changes: 19 additions & 16 deletions lib/apps.js
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand All @@ -54,3 +49,11 @@ Apps.list = function (args) {
}
});
}

var Apps = {
usage: usage,
run: list,
list: list
};

module.exports = Apps;
45 changes: 24 additions & 21 deletions lib/commands.js
Expand Up @@ -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')
Expand Down Expand Up @@ -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());
});
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -176,11 +179,11 @@ function showUsage () {
cmds[i].usage();
}
}
};
}

module.exports = {
commands : commands,
run : run,
showHelp : showHelp,
log : log
}
};

0 comments on commit feeb80f

Please sign in to comment.