Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit f49d032

Browse files
committed
bug #139 Don't create README.md on cleanup (xelaris)
This PR was merged into the 1.0-dev branch. Discussion ---------- Don't create README.md on cleanup In case of an exception, e.g. when typing an invalid version number, the `cleanUp` method gets called. Since the `README.md` file was dumped there, the target directory wasn't empty on the next try, so it wasn't possible to re-run the command without manually removing the file. Commits ------- a4198d6 Don't create README.md on cleanup
2 parents ae8f886 + a4198d6 commit f49d032

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/Symfony/Installer/NewCommand.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5858
->download()
5959
->extract()
6060
->cleanUp()
61+
->dumpReadmeFile()
6162
->updateParameters()
6263
->updateComposerJson()
6364
->createGitIgnore()
@@ -202,9 +203,6 @@ protected function cleanUp()
202203

203204
$filesToRemove = array_merge($licenseFile, $upgradeFiles, $changelogFiles);
204205
$this->fs->remove($filesToRemove);
205-
206-
$readmeContents = sprintf("%s\n%s\n\nA Symfony project created on %s.\n", $this->projectName, str_repeat('=', strlen($this->projectName)), date('F j, Y, g:i a'));
207-
$this->fs->dumpFile($this->projectDir.'/README.md', $readmeContents);
208206
} catch (\Exception $e) {
209207
// don't throw an exception in case any of the Symfony-related files cannot
210208
// be removed, because this is just an enhancement, not something mandatory
@@ -262,6 +260,25 @@ protected function displayInstallationResult()
262260
return $this;
263261
}
264262

263+
/**
264+
* Dump a basic README.md file.
265+
*
266+
* @return NewCommand
267+
*/
268+
protected function dumpReadmeFile()
269+
{
270+
$readmeContents = sprintf("%s\n%s\n\nA Symfony project created on %s.\n", $this->projectName, str_repeat('=', strlen($this->projectName)), date('F j, Y, g:i a'));
271+
try {
272+
$this->fs->dumpFile($this->projectDir.'/README.md', $readmeContents);
273+
} catch (\Exception $e) {
274+
// don't throw an exception in case the file could not be created,
275+
// because this is just an enhancement, not something mandatory
276+
// for the project
277+
}
278+
279+
return $this;
280+
}
281+
265282
/**
266283
* Updates the Symfony parameters.yml file to replace default configuration
267284
* values with better generated values.

0 commit comments

Comments
 (0)