public function findPackage($search, $ignore_exception = false)
    {
        $search = strtolower($search);

        $found = $this->getRepositoryTheme($search);
        if ($found) {
            return $found;
        }

        $found = $this->getRepositoryPlugin($search);
        if ($found) {
            return $found;
        }

        $themes = $this->getRepositoryThemes();
        $plugins = $this->getRepositoryPlugins();

        if (!$themes && !$plugins) {
            if (!is_writable(ROOT_DIR . '/cache/gpm')) {
                throw new \RuntimeException("The cache/gpm folder is not writable. Please check the folder permissions.");
            }

            if ($ignore_exception) {
                return false;
            }

            throw new \RuntimeException("GPM not reachable. Please check your internet connection or check the Grav site is reachable");
        }

        if ($themes) {
            foreach ($themes as $slug => $theme) {
                if ($search == $slug || $search == $theme->name) {
                    return $theme;
                }
            }
        }

        if ($plugins) {
            foreach ($plugins as $slug => $plugin) {
                if ($search == $slug || $search == $plugin->name) {
                    return $plugin;
                }
            }
        }

        return false;
    }