mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-24 09:12:51 +01:00
Adding a task to clean files and/or directoies
This commit is contained in:
parent
0d12b3b219
commit
b36b1ede9c
@ -15,6 +15,8 @@ set('copy_dirs', []);
|
|||||||
set('writable_dirs', []);
|
set('writable_dirs', []);
|
||||||
set('writable_use_sudo', true); // Using sudo in writable commands?
|
set('writable_use_sudo', true); // Using sudo in writable commands?
|
||||||
set('http_user', null);
|
set('http_user', null);
|
||||||
|
set('clear_paths', []); // Relative path from deploy_path
|
||||||
|
set('clear_use_sudo', true); // Using sudo in clean commands?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Environment vars
|
* Environment vars
|
||||||
@ -372,6 +374,18 @@ task('cleanup', function () {
|
|||||||
|
|
||||||
})->desc('Cleaning up old releases');
|
})->desc('Cleaning up old releases');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup files and directories
|
||||||
|
*/
|
||||||
|
task('deploy:clean', function () {
|
||||||
|
$paths = get('clear_paths');
|
||||||
|
$sudo = get('clear_use_sudo') ? 'sudo' : '';
|
||||||
|
|
||||||
|
foreach ($paths as $path) {
|
||||||
|
run("$sudo rm -rf {{deploy_path}}/$path");
|
||||||
|
}
|
||||||
|
|
||||||
|
})->desc('Cleaning up files and/or directories');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Success message
|
* Success message
|
||||||
|
@ -134,6 +134,20 @@ class CommonTest extends RecipeTester
|
|||||||
$this->assertEquals(3, iterator_count($fi));
|
$this->assertEquals(3, iterator_count($fi));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test clean
|
||||||
|
*/
|
||||||
|
public function testClean()
|
||||||
|
{
|
||||||
|
set('clear_paths', ['current/app/README.md', 'current/app/tests']);
|
||||||
|
set('clear_use_sudo', false);
|
||||||
|
|
||||||
|
$this->exec('deploy:clean');
|
||||||
|
|
||||||
|
$this->assertFileNotExists($this->getEnv('deploy_path') . '/current/app/README.md');
|
||||||
|
$this->assertFileNotExists($this->getEnv('deploy_path') . '/current/app/tests');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @depends testCleanup
|
* @depends testCleanup
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user