private function clean(InputInterface $input, OutputInterface $output, string $dir): void
    {
        $fileSystem = $this->getContainer()->get('filesystem');

        if ($fileSystem->exists($dir)) {
            if ($input->isInteractive()) {
                // Prompt the user for confirmation.
                /** @var QuestionHelper $helper */
                $helper = $this->getHelper('question');
                $question = new ConfirmationQuestion(sprintf(
                    'Are you sure you want to delete all the contents of the %s directory?',
                    $dir
                ), false);

                if (!$helper->ask($input, $output, $question)) {
                    return;
                }
            }

            $output->writeln(sprintf('Deleting %s', $dir));
            $fileSystem->remove($dir);
        }
    }