Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

UX Fix #335

Merged
merged 5 commits into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 8, 2012
  1. @yawnt

    [feature] ui

    yawnt authored
  2. @yawnt

    [fix] default

    yawnt authored
  3. @yawnt

    [fix] typo

    yawnt authored
  4. @yawnt

    [fix] function name

    yawnt authored
  5. @yawnt

    [refactor] cleanup

    yawnt authored
This page is out of date. Refresh to see the latest.
Showing with 34 additions and 17 deletions.
  1. +34 −17 lib/jitsu/commands/databases.js
View
51 lib/jitsu/commands/databases.js
@@ -113,32 +113,49 @@ databases.create = function (requestedDatabaseType, requestedDatabaseName, callb
}
function promptForDatabase (callback) {
- var getProperties = [];
+
+ var funcs = [
+ function getDBName(cb) {
+ if(database.name) {
+ return cb();
+ }
- if (!database.name || !database.type) {
- if (!database.name) {
jitsu.log.error('Database name is required');
- getProperties.push({
+ jitsu.prompt.get({
name: 'database name',
default: database.type
+ }, function(e, res) {
+ database.name = res['database name'] || database.name;
+ cb();
});
- }
+ },
- if (!database.type) {
- jitsu.log.warn('Valid database types are: ' + 'couch'.magenta + ', ' + 'redis'.magenta + ', or ' + 'mongo'.magenta);
- getProperties.push('database type');
+ function getDBType(cb) {
+ if(database.type) {
+ return cb();
+ }
+
+ jitsu.log.warn('Valid database types are: ' + 'couch'.magenta + ', ' + 'redis'.magenta +', or ' + 'mongo'.magenta);
+ jitsu.prompt.get('database type', function(e, res) {
+ database.type = res['database type'] || database.type;
+ cb();
+ });
+ }
+ ];
+
+
+ (function iterate(keys) {
+ var elem = funcs[--keys];
+
+ if(!elem) {
+ return createDatabase(database, callback);
}
- }
- if (!getProperties.length) {
- return createDatabase(database, callback);
- }
+ elem(function dbIterator() {
+ iterate(keys);
+ });
- jitsu.prompt.get(getProperties, function (err, result) {
- database.type = result['database type'] || database.type;
- database.name = result['database name'] || database.name;
- createDatabase(database, callback);
- });
+ })(funcs.length);
}
promptForDatabase(callback);
Something went wrong with that request. Please try again.