diff --git a/php/.nostow b/php/.nostow new file mode 100644 index 0000000..870761b --- /dev/null +++ b/php/.nostow @@ -0,0 +1,4 @@ +argvParser.php +functions.php +snips.php +api_key diff --git a/php/bin/stow b/php/bin/stow index f389769..d56a7e3 100755 --- a/php/bin/stow +++ b/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);