diff --git a/src/Construct.php b/src/Construct.php index ee2cbd3..d2ef244 100644 --- a/src/Construct.php +++ b/src/Construct.php @@ -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'; } diff --git a/tests/Commands/ConstructCommandTest.php b/tests/Commands/ConstructCommandTest.php index f82ab1c..a268697 100644 --- a/tests/Commands/ConstructCommandTest.php +++ b/tests/Commands/ConstructCommandTest.php @@ -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'); diff --git a/tests/ConstructTest.php b/tests/ConstructTest.php index 8a477f8..e6b019b 100644 --- a/tests/ConstructTest.php +++ b/tests/ConstructTest.php @@ -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() diff --git a/tests/stubs/with-env/gitignore.stub b/tests/stubs/with-env/gitignore.stub new file mode 100644 index 0000000..e7da332 --- /dev/null +++ b/tests/stubs/with-env/gitignore.stub @@ -0,0 +1,4 @@ +# composer +/vendor/ +phpunit.xml +.env