protected function writeToFileFromTemplate($path, $templateName, OutputInterface $output = null, array $variables = [], $overwrite = false)
    {
        if ($overwrite || (!file_exists($path) && !is_dir($path))) {
            $dir = dirname($path);
            if (!file_exists($dir) || !is_dir($dir)) {
                mkdir($dir, 0777, true);
            }

            file_put_contents($path, $this->renderTemplate($templateName, $variables));
            $output->writeln('<info>File created:</info> ' . $path);
        } else {
            $output->writeln('<info>File already exists:</info> ' . $path . ' <comment>(Overwrite disabled)</comment>');
        }
    }