lib/package.js
function findMainFile(wpPackage) {
  if (wpPackage.isType('wp-theme')) {
    return 'style.css';
  }

  var found = '';
  var pluginFile = guessSlug(wpPackage) + '.php';
  var filename = wpPackage.getPath(pluginFile);

  // Check if the main file exists.
  if (util.fileExists(filename) && wpPackage.getHeader('Plugin Name', filename)) {
    return pluginFile;
  }

  // Search for plugin headers in php files in the main directory.
  glob.sync('*.php', {
    cwd: wpPackage.getPath()
  }).forEach(function(file) {
    var filename = wpPackage.getPath(file);

    if (wpPackage.getHeader('Plugin Name', filename)) {
      found = file;
    }
  });

  return found;
}
function findMainFile(wpPackage) {
  if (wpPackage.isType('wp-theme')) {
    return 'style.css';
  }

  var found = '';
  var pluginFile = guessSlug(wpPackage) + '.php';
  var filename = wpPackage.getPath(pluginFile);

  // Check if the main file exists.
  if (util.fileExists(filename) && wpPackage.getHeader('Plugin Name', filename)) {
    return pluginFile;
  }

  // Search for plugin headers in php files in the main directory.
  glob.sync('*.php', {
    cwd: wpPackage.getPath()
  }).forEach(function(file) {
    var filename = wpPackage.getPath(file);

    if (wpPackage.getHeader('Plugin Name', filename)) {
      found = file;
    }
  });

  return found;
}
function findMainFile ( wpPackage ) { if ( wpPackage . isType ( 'wp-theme' ) ) { return 'style.css' ; } var found = '' ; var pluginFile = guessSlug ( wpPackage ) + '.php' ; var filename = wpPackage . getPath ( pluginFile ) ; // Check if the main file exists. if ( util . fileExists ( filename ) && wpPackage . getHeader ( 'Plugin Name' , filename ) ) { return pluginFile ; } // Search for plugin headers in php files in the main directory. glob . sync ( '*.php' , { cwd : wpPackage . getPath ( ) } ) . forEach ( function ( file ) { var filename = wpPackage . getPath ( file ) ; if ( wpPackage . getHeader ( 'Plugin Name' , filename ) ) { found = file ; } } ) ; return found ; }
Discover the main package file.

For themes, the main file will be style.css. The main file for plugins
contains the plugin headers.

@param {WPPackage} wpPackage Package object.
@returns {string}
Discover the main package file .