Searches all plugin paths and returns an Array of file paths to plugins

 @param dir [Array, String] directory/directories to load plugins from
 @return [Array<String>]
496459
def plugin_files_by_dir(plugin_dir = Ohai.config[:plugin_path])
      Array(plugin_dir).map do |path|
        if Dir.exist?(path)
          Ohai::Log.trace("Searching for Ohai plugins in #{path}")

          escaped = ChefConfig::PathHelper.escape_glob_dir(path)
          Dir[File.join(escaped, "**", "*.rb")]
        else
          Ohai::Log.debug("The plugin path #{path} does not exist. Skipping...")
          []
        end
      end.flatten
    end
343788
function (pluginsPath) {
    var plugins = fs.readdirSync(pluginsPath);
    var loadedPlugin = [];
    plugins.forEach(function (pluginName) {
        if (pluginName !== 'index.js') {
            loadedPlugin.push(require(path.resolve(pluginsPath, path.basename(pluginName, '.js'))));
        }
    });
    return loadedPlugin;
}
247448
def list_plugins(directory=None):
    """"""
    repo = require_repo(directory)
    plugins = get_value(repo, 'plugins')
    if not plugins or not isinstance(plugins, dict):
        return None
    return plugins.keys()
1068865
def each_file(&bl)
      unpack do |dir|
        Pathname.new(dir).find do |path|
          next if path.to_s == dir.to_s
          pathstr = path.to_s.gsub("#{dir}/", '')
          bl.call pathstr unless pathstr.blank?
        end
      end
    end
969833
def load_plugins(plugins)
      unless plugins.is_a?(Array)
        raise ArgumentError, "load_plugins expects an array, got #{plugins.inspect}"
      end

      plugins.each do |plugin|
        plugin_file = plugin.start_with?("/") ? plugin : File.expand_path("../../#{plugin}", File.dirname(__FILE__))
        unless File.file?(plugin_file)
          raise Errno::ENOENT, "Failed to find plugin #{plugin.inspect} at #{plugin_file}"
        end
        require plugin_file
      end
    end
467657
function getModulesByDir (dir, scope = '') {
  const nodeModulesDir = getNodeModulesDir()
  const results = []
  const modules = fs.readdirSync(dir)

  if (!modules.length) {
    return results
  }

  modules.forEach(module => {
    if (module.startsWith('.')) {

    } else if (module.startsWith('@')) {
      const subDir = path.join(nodeModulesDir, module)
      const subModules = getModulesByDir(subDir, module)
      Array.prototype.push.call(results, ...subModules)
    } else {
      results.push(scope ? `${scope}/${module}` : module)
    }
  })

  return results
}
1343590
function loadPluginsFromDir(dir, config) {
  try {
    fs
      .readdirSync(dir)
      .filter(resource => {
        if (path.basename(dir) != 'plugins') return RE_PLUGIN.test(resource);
        return RE_JS_FILE.test(resource) || fs.statSync(path.join(dir, resource)).isDirectory();
      })
      .forEach(resource => {
        registerPlugin(path.join(dir, resource), config);
      });
  } catch (err) {
    /* ignore */
  }
}
1188935
function loadFiles(directories, files)
{
  // sort extensions to provide deterministic order of loading
  var _instance  = this
    , extensions = resolveExts.call(this)
    , layers     = []
    ;

  // treat all inputs as list of directories
  directories = (typeOf(directories) == 'array') ? directories : [directories];

  files.forEach(function(filename)
  {
    var layer = {file: filename, exts: []};

    extensions.forEach(function(ext)
    {
      var layerExt = {ext: ext, dirs: []};

      directories.forEach(function(dir)
      {
        var cfg, file = path.resolve(dir, filename + '.' + ext);

        if (fs.existsSync(file))
        {
          cfg = loadContent.call(_instance, file, _instance.parsers[ext]);

          // check if any hooks needed to be applied
          cfg = applyHooks.call(_instance, cfg, filename);
        }

        if (cfg)
        {
          layerExt.dirs.push({
            dir   : dir,
            config: cfg
          });
        }
      });

      // populate with non-empty layers only
      if (layerExt.dirs.length)
      {
        layer.exts.push(layerExt);
      }
    });

    // populate with non-empty layers only
    if (layer.exts.length)
    {
      layers.push(layer);
    }

  });

  return layers;
}
1350964
def get_plugins_from_dir(dir_path, classbase):
    """"""

    if dir_path == "sys":
        dir_path = os.path.abspath(
            os.path.join(os.path.dirname(__file__), 'plugins'))
        dir_plugins = get_plugins(dir_path)
        return {"dir": dir_path, "plugins": dir_plugins, "class": classbase}

    if dir_path == ".":
        dir_path = os.path.expanduser(
            os.path.expandvars(os.path.join(os.getcwd(), 'plugins')))
        dir_plugins = get_plugins(dir_path)
        return {"dir": dir_path, "plugins": dir_plugins, "class": classbase}
    else:

        dir_path = os.path.expanduser(os.path.expandvars(dir_path))
        prefix = "{0}/{1}".format(dir_path, classbase)

        user_path = "{0}/plugins".format(prefix)

        create_dir(user_path)
        create_file("{0}/__init__.py".format(prefix))
        create_file("{0}/plugins/__init__.py".format(prefix))
        sys.path.append(os.path.expanduser(dir_path))
        dir_plugins = get_plugins(user_path)
        # pprint({"dir": dir_path, "plugins": dir_plugins, "class": classbase})
        return {"dir": dir_path, "plugins": dir_plugins, "class": classbase}
325907
def load_plugins(self, plugins_package):
        '''  '''
        try:
            # Resolve directory in the filesystem
            plugin_dir = find_spec(plugins_package).submodule_search_locations[0]
        except ImportError:
            logger.error(
                "Could not load plugins package '%(pkg)s'", {'pkg': plugins_package}
            )
            return

        for module_path in self._get_plugin_module_paths(plugin_dir):
            # Load the module dynamically
            spec = find_spec('{}.{}'.format(plugins_package, module_path))
            m = module_from_spec(spec)
            spec.loader.exec_module(m)

            # Get classes from module and extract the plugin classes
            classes = inspect.getmembers(m, predicate=inspect.isclass)
            for _, klass in classes:
                # Avoid imports processing
                if klass.__module__ != spec.name:
                    continue

                # Avoid classes not ending in Plugin
                if not klass.__name__.endswith('Plugin'):
                    continue

                instance = klass()
                if self._is_plugin_ok(instance):
                    self.plugins.add(instance)
761482
def paths
      relative_paths = gem_names.flat_map do |plugin|
        Dir.glob("vendor/gems/ruby/*/gems/#{plugin}*/lib/**/**/**/**.rb")
      end

      relative_paths.map { |path| File.join(dir, path) }
    end
228201
def setup_directories(options)
      @directories = options[:directories] || []
      [
        'app/assets/javascripts',
        'app/assets/stylesheets',
        'app/views/components'
      ].each { |known_dir|
        if !@directories.include?(known_dir) && File.exists?(known_dir)
          @directories << known_dir
        end
      }
    end
408773
function getFiles(dir) {
    var files = [];

    var traverse = function (dir) {
        var dirList = dir.listFiles();
        dirList.forEach(function (file) {
            if (/\.css$/.test(file)) {
                files.push(file);
            } else if (file.isDirectory()) {
                traverse(file);
            }
        });
    };

    traverse(dir);

    return files;
}
585871
def files
    @files ||= lambda {
      sorted_relevant_files = []

      file_globs.each do |glob|
        current_glob_files  = Pathname.glob(glob)
        relevant_glob_files = relevant_files & current_glob_files

        relevant_glob_files.map! do |file|
          File.new(path:            file,
                   namespaces:      namespaces,
                   decryption_keys: decryption_keys,
                   encryption_keys: encryption_keys)
        end

        sorted_relevant_files += relevant_glob_files
      end

      sorted_relevant_files.uniq
    }.call
  end
1081372
def load_plugins_dir(path, category=None, overwrite=False):
    
    # get potential plugin python files
    if hasattr(path, 'glob'):
        pypaths = path.glob('*.py')
    else:
        pypaths = glob.glob(os.path.join(path, '*.py'))

    load_errors = []
    for pypath in pypaths:
        # use uuid to ensure no conflicts in name space
        mod_name = str(uuid.uuid4())
        try:
            if hasattr(pypath, 'resolve'):
                # Make the path absolute, resolving any symlinks
                pypath = pypath.resolve()

            with warnings.catch_warnings(record=True):
                warnings.filterwarnings("ignore", category=ImportWarning)

                # for MockPaths
                if hasattr(pypath, 'maketemp'):
                    with pypath.maketemp() as f:
                        module = load_source(mod_name, f.name)
                else:
                    module = load_source(mod_name, str(pypath))

        except Exception as err:
            load_errors.append((str(pypath), 'Load Error: {}'.format(err)))
            continue

        # only get classes that are local to the module
        class_members = inspect.getmembers(module, inspect.isclass)
        classes = [klass for klass_name, klass in class_members if
                   klass.__module__ == mod_name]
        load_errors += load_plugin_classes(classes, category, overwrite)

    return load_errors
655187
function resolveDir(directories)
{
  var directoriesAbsPath;

  if (typeOf(directories) == 'array')
  {
    directoriesAbsPath = directories.map(function(d)
    {
      return path.resolve(d);
    }).join('|');
  }
  else
  {
    directoriesAbsPath = path.resolve(directories);
  }

  return directoriesAbsPath;
}
764764
function pluginFolder () {
  const path = sketchtoolExec('show plugins');
  invariant(path, 'Plugin folder not found!');
  invariant(fs.existsSync(path), `Plugin folder does not exist at ${path}!`);
  return path;
}