Airship\Hangar\Commands\Sign::selectFile PHP Method

selectFile() protected method

Select which file to sign
protected selectFile ( string $filename = '' ) : string
$filename string
return string
    protected function selectFile(string $filename = '') : string
    {
        if (!empty($filename)) {
            // Did we get passed an absolute path?
            if ($filename[0] === '/') {
                if (!\file_exists($filename)) {
                    throw new \Error('File not found: ' . $filename);
                }
                return $filename;
            }
            $dir = \getcwd();
            $path = \realpath($dir . DIRECTORY_SEPARATOR . $filename);
            if (!\file_exists($path)) {
                // Ok, try in the Airship config directory then?
                $path = \realpath(AIRSHIP_LOCAL_CONFIG . DIRECTORY_SEPARATOR . $filename);
                if (!\file_exists($path)) {
                    throw new \Error('File not found: ' . $filename);
                }
            }
            return $path;
        }
        // Let's grab it from our build history then, eh?
        $files = $this->config['build_history'] ?? [];
        if (empty($files)) {
            throw new \Error('No recent builds. Try specifying ');
        }
        $keys = \array_keys($files);
        $this->history = \array_pop($keys);
        $last = $files[$this->history];
        return $last['path'];
    }