lib/app/registry.js
function(app) {

  var filepath = path.join(app.dir, APP_CONFIG_FILENAME);

  // Read contents of file.
  return Promise.fromNode(function(cb) {
    fs.readFile(filepath, {encoding: 'utf8'}, cb);
  })
  // Handle no entry error.
  .catch(function(err) {
    if (err.code === 'ENOENT') {
      cacheBadApp(app);
    } else {
      throw new VError(err, 'Failed to load config: %s', filepath);
    }
  })
  // Return appName.
  .then(function(data) {
    var json = util.yaml.dataToJson(data);
    if (!json) {
      return null;
    }
    else if (!json.name) {
      log.debug(format('Does NOT contain %s property!', filepath));
      return null;
    }
    else if (json.name === app.name) {
      cacheApp(app);
      return app;
    }
    else if (json.name !== app.name) {
      cacheBadApp(app);
      return null;
    }
    else {
      return null;
    }
  });

}
function(app) {

  var filepath = path.join(app.dir, APP_CONFIG_FILENAME);

  // Read contents of file.
  return Promise.fromNode(function(cb) {
    fs.readFile(filepath, {encoding: 'utf8'}, cb);
  })
  // Handle no entry error.
  .catch(function(err) {
    if (err.code === 'ENOENT') {
      cacheBadApp(app);
    } else {
      throw new VError(err, 'Failed to load config: %s', filepath);
    }
  })
  // Return appName.
  .then(function(data) {
    var json = util.yaml.dataToJson(data);
    if (!json) {
      return null;
    }
    else if (!json.name) {
      log.debug(format('Does NOT contain %s property!', filepath));
      return null;
    }
    else if (json.name === app.name) {
      cacheApp(app);
      return app;
    }
    else if (json.name !== app.name) {
      cacheBadApp(app);
      return null;
    }
    else {
      return null;
    }
  });

}
function ( app ) { var filepath = path . join ( app . dir , APP_CONFIG_FILENAME ) ; // Read contents of file. return Promise . fromNode ( function ( cb ) { fs . readFile ( filepath , { encoding : 'utf8' } , cb ) ; } ) // Handle no entry error. . catch ( function ( err ) { if ( err . code === 'ENOENT' ) { cacheBadApp ( app ) ; } else { throw new VError ( err , 'Failed to load config: %s' , filepath ) ; } } ) // Return appName. . then ( function ( data ) { var json = util . yaml . dataToJson ( data ) ; if ( ! json ) { return null ; } else if ( ! json . name ) { log . debug ( format ( 'Does NOT contain %s property!' , filepath ) ) ; return null ; } else if ( json . name === app . name ) { cacheApp ( app ) ; return app ; } else if ( json . name !== app . name ) { cacheBadApp ( app ) ; return null ; } else { return null ; } } ) ; }
Given an app, inspect it and return the appName.
Given an app inspect it and return the appName .