Skip to content

Commit

Permalink
Merge pull request #6118 from Codeception/4.1-clean-keep-gitkeep-files
Browse files Browse the repository at this point in the history
Clean: Do not delete .gitkeep files
  • Loading branch information
Naktibalda committed Feb 23, 2021
2 parents 3ec3d35 + d75af9a commit 83c8413
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Codeception/Util/FileSystem.php
Expand Up @@ -20,7 +20,7 @@ public static function doEmptyDir($path)

foreach ($iterator as $path) {
$basename = basename((string)$path);
if ($basename === '.' || $basename === '..' || $basename === '.gitignore') {
if ($basename === '.' || $basename === '..' || $basename === '.gitignore' || $basename === '.gitkeep') {
continue;
}

Expand Down
21 changes: 21 additions & 0 deletions tests/cli/CleanCest.php
@@ -0,0 +1,21 @@
<?php

class CleanCest
{
public function cleanDoesNotDeleteGitKeepFiles(\CliGuy $I)
{
$ds = DIRECTORY_SEPARATOR;

$I->amInPath('tests/data/included');
$I->executeCommand('clean');
$I->seeInShellOutput("included{$ds}_log");
$I->seeInShellOutput("included{$ds}jazz{$ds}tests/_log");
$I->seeInShellOutput("included{$ds}jazz{$ds}pianist{$ds}tests/_log");
$I->seeInShellOutput("included{$ds}shire{$ds}tests/_log");
$I->seeInShellOutput('Done');
$I->seeFileFound("_log/.gitkeep");
$I->seeFileFound("jazz{$ds}tests/_log/.gitkeep");
$I->seeFileFound("jazz{$ds}pianist{$ds}tests/_log/.gitkeep");
$I->seeFileFound("shire{$ds}tests/_log/.gitkeep");
}
}
1 change: 0 additions & 1 deletion tests/cli/IncludedCest.php
Expand Up @@ -6,7 +6,6 @@ public function _before()
{
$logDir = codecept_root_dir('tests/data/included/_log');
\Codeception\Util\FileSystem::doEmptyDir($logDir);
file_put_contents($logDir . '/.gitkeep', '');
}

/**
Expand Down

0 comments on commit 83c8413

Please sign in to comment.