Implement quick version of .nostow file to prevent certain stows
This commit is contained in:
parent
7ad7c8d220
commit
b690b588c5
4
php/.nostow
Normal file
4
php/.nostow
Normal file
@ -0,0 +1,4 @@
|
||||
argvParser.php
|
||||
functions.php
|
||||
snips.php
|
||||
api_key
|
18
php/bin/stow
18
php/bin/stow
@ -9,12 +9,26 @@ readonly class stow
|
||||
public function __construct(
|
||||
private string $action = 'stow',
|
||||
private bool $backup = false,
|
||||
private bool $force = false
|
||||
private bool $force = false,
|
||||
) {}
|
||||
|
||||
private function getNoStow(string $path): array
|
||||
{
|
||||
if (file_exists(path($path, '.nostow'))) {
|
||||
$noStow = file_get_contents(path($path, '.nostow'));
|
||||
if ($noStow === false) {
|
||||
return [];
|
||||
}
|
||||
return array_values(array_filter(array_map('trim', explode(PHP_EOL, $noStow))));
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function run(string $sourcePath, string $targetPath): void
|
||||
{
|
||||
$sourceFiles = array_diff(scandir($sourcePath), ['..', '.']);
|
||||
$noStow = $this->getNoStow($sourcePath);
|
||||
$sourceFiles = array_diff(scandir($sourcePath), ['..', '.', '.nostow', ...$noStow]);
|
||||
|
||||
foreach ($sourceFiles as $sourceFile) {
|
||||
$targetFile = path($targetPath, $sourceFile);
|
||||
|
Loading…
x
Reference in New Issue
Block a user