Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Three little fixes #45

Merged
merged 2 commits into from
Apr 30, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 14 additions & 21 deletions lib/commands.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,34 @@
var log = require('./log');
brand = "nodester",
apihost = "api.nodester.com",
apisecure = false,
env = process.env,
fs = require('fs');


cfg = process.nodester || (process.nodester = {})

process.argv = process.argv.slice(2);

if (env.NODESTER_APIHOST) {
apihost = env.NODESTER_APIHOST;
cfg.apihost = env.NODESTER_APIHOST;
}
if (env.NODESTER_APISECURE) {
apisecure = true;
cfg.apisecure = true;
}
if (env.NODESTER_BRAND) {
brand = env.NODESTER_BRAND;
cfg.brand = env.NODESTER_BRAND;
}


var nodester_config = {
apisecure: apisecure,
apihost: apihost,
brand: brand,
var defaults = {
apisecure: false,
apihost: "api.nodester.com",
brand: "nodester",
appname: '',
config: {
username: '',
password: ''
}
};
if (!process.nodester) {
process.nodester = {};
}
for (var i in nodester_config) {
if (!process.nodester[i]) {
process.nodester[i] = nodester_config[i];
for (var i in defaults) {
if (!cfg[i]) {
cfg[i] = defaults[i];
}
}

Expand Down Expand Up @@ -89,8 +82,8 @@ exports.run = function(cmds, command) {
showHelp(exports.commands);
process.exit(1);
}
if (!cmds[command] && process.nodester.appname) {

if (!cmds[command] && cfg.appname) {
command = 'app';
process.argv.unshift('app');
}
Expand Down Expand Up @@ -122,7 +115,7 @@ var showHelp = exports.showHelp = function(args) {
log.usage(i);
}
}
log.info('For more help, type', brand, 'help <command>');
log.info('For more help, type', cfg.brand, 'help <command>');
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ exports.writeApp = function(appname, folder) {
if (!folder) {
folder = '';
}
if(!exists(folder)){
fs.mkdirSync(folder, '0777');
else if(!exists(folder)) {
fs.mkdirSync(folder, '0777');
}
var config_file = path.join("./" + folder, "." + process.nodester.brand + ".appconfig");
log.info('Writing app data to config in ' + config_file);
Expand Down