Skip to content

Commit

Permalink
Merge pull request #118 from raphaelstolt/env-gitignore-fix
Browse files Browse the repository at this point in the history
Constructed .env is added to .gitignore. Fixes #117.
  • Loading branch information
jonathantorres committed Apr 15, 2016
2 parents 98fb7be + f56cf2c commit 56395b7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/Construct.php
Expand Up @@ -284,7 +284,15 @@ protected function changelog()
*/
protected function gitignore()
{
$this->file->copy(__DIR__ . '/stubs/gitignore.stub', $this->projectLower . '/' . '.gitignore');
if ($this->settings->withEnvironmentFiles()) {
$content = $this->file->get(__DIR__ . '/stubs/gitignore.stub');
$content .= '.env' . PHP_EOL;

$this->file->put($this->projectLower . '/' . '.gitignore', $content);
} else {
$this->file->copy(__DIR__ . '/stubs/gitignore.stub', $this->projectLower . '/' . '.gitignore');
}

$this->exportIgnores[] = '.gitignore';
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Commands/ConstructCommandTest.php
Expand Up @@ -300,7 +300,7 @@ public function testProjectGenerationWithEditorConfig()

public function testProjectGenerationWithEnvironmentFiles()
{
$this->setMocks(3, 2, 3);
$this->setMocks(3, 2, 2, 11, 11);

$app = $this->setApplication();
$command = $app->find('generate');
Expand Down
1 change: 1 addition & 0 deletions tests/ConstructTest.php
Expand Up @@ -465,6 +465,7 @@ public function testProjectGenerationWithEnvironmentFiles()
$this->assertSame($this->getStub('with-env/env'), $this->getFile('.env.example'));
$this->assertSame($this->getStub('with-env/gitattributes'), $this->getFile('.gitattributes'));
$this->assertSame($this->getStub('with-env/composer'), $this->getFile('composer.json'));
$this->assertSame($this->getStub('with-env/gitignore'), $this->getFile('.gitignore'));
}

public function testProjectGenerationWithLgtmConfiguration()
Expand Down
4 changes: 4 additions & 0 deletions tests/stubs/with-env/gitignore.stub
@@ -0,0 +1,4 @@
# composer
/vendor/
phpunit.xml
.env

0 comments on commit 56395b7

Please sign in to comment.