Skip to content

Commit d75af9a

Browse files
committed
Clean: Do not delete .gitkeep files
Because they are often used in _output directories
1 parent 532cbb7 commit d75af9a

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/Codeception/Util/FileSystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static function doEmptyDir($path)
2020

2121
foreach ($iterator as $path) {
2222
$basename = basename((string)$path);
23-
if ($basename === '.' || $basename === '..' || $basename === '.gitignore') {
23+
if ($basename === '.' || $basename === '..' || $basename === '.gitignore' || $basename === '.gitkeep') {
2424
continue;
2525
}
2626

tests/cli/CleanCest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
class CleanCest
4+
{
5+
public function cleanDoesNotDeleteGitKeepFiles(\CliGuy $I)
6+
{
7+
$ds = DIRECTORY_SEPARATOR;
8+
9+
$I->amInPath('tests/data/included');
10+
$I->executeCommand('clean');
11+
$I->seeInShellOutput("included{$ds}_log");
12+
$I->seeInShellOutput("included{$ds}jazz{$ds}tests/_log");
13+
$I->seeInShellOutput("included{$ds}jazz{$ds}pianist{$ds}tests/_log");
14+
$I->seeInShellOutput("included{$ds}shire{$ds}tests/_log");
15+
$I->seeInShellOutput('Done');
16+
$I->seeFileFound("_log/.gitkeep");
17+
$I->seeFileFound("jazz{$ds}tests/_log/.gitkeep");
18+
$I->seeFileFound("jazz{$ds}pianist{$ds}tests/_log/.gitkeep");
19+
$I->seeFileFound("shire{$ds}tests/_log/.gitkeep");
20+
}
21+
}

tests/cli/IncludedCest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ public function _before()
66
{
77
$logDir = codecept_root_dir('tests/data/included/_log');
88
\Codeception\Util\FileSystem::doEmptyDir($logDir);
9-
file_put_contents($logDir . '/.gitkeep', '');
109
}
1110

1211
/**

0 commit comments

Comments
 (0)