protected function normalizeTargetDir($target)
    {
        $target = rtrim(Yii::getAlias($target), '\\/');
        if (file_exists($target)) {
            if (is_dir($target) && !$this->confirm('TargetDirectory already exists. Overwrite?', true)) {
                $this->stderr('User aborted.' . PHP_EOL);

                return false;
            }
            if (is_file($target)) {
                $this->stderr("Error: Target directory \"$target\" is a file!" . PHP_EOL);

                return false;
            }
        } else {
            mkdir($target, 0777, true);
        }

        return $target;
    }