lib/app.js
function rec(counter) {
    // Format next app name to check for.
    var name = counter ?
      util.format(opts.template, appName, counter) :
      appName;
    // Check if app name exists.
    return exists(name)
    .then(function(exists) {
      // App name already exists.
      if (exists) {
        // We've checked for a reasonable amount of app names without finding
        // one so just return original app name.
        if (counter > 255) {
          return appName;
        // Recurse with an incremented counter.
        } else if (!counter) {
          return rec(1);
        // Recurse with an incremented counter.
        } else {
          return rec(counter + 1);
        }
      // App name does NOT already exist, we found it!
      } else {
        return name;
      }
    });
  }
function rec(counter) {
    // Format next app name to check for.
    var name = counter ?
      util.format(opts.template, appName, counter) :
      appName;
    // Check if app name exists.
    return exists(name)
    .then(function(exists) {
      // App name already exists.
      if (exists) {
        // We've checked for a reasonable amount of app names without finding
        // one so just return original app name.
        if (counter > 255) {
          return appName;
        // Recurse with an incremented counter.
        } else if (!counter) {
          return rec(1);
        // Recurse with an incremented counter.
        } else {
          return rec(counter + 1);
        }
      // App name does NOT already exist, we found it!
      } else {
        return name;
      }
    });
  }
function rec ( counter ) { // Format next app name to check for. var name = counter ? util . format ( opts . template , appName , counter ) : appName ; // Check if app name exists. return exists ( name ) . then ( function ( exists ) { // App name already exists. if ( exists ) { // We've checked for a reasonable amount of app names without finding // one so just return original app name. if ( counter > 255 ) { return appName ; // Recurse with an incremented counter. } else if ( ! counter ) { return rec ( 1 ) ; // Recurse with an incremented counter. } else { return rec ( counter + 1 ) ; } // App name does NOT already exist, we found it! } else { return name ; } } ) ; }
Recursive function for finding unique app name.
Recursive function for finding unique app name .