Skip to content
This repository has been archived by the owner on May 9, 2021. It is now read-only.

.DS_Store removal from folders #22

Open
orukaz opened this issue Oct 6, 2020 · 0 comments
Open

.DS_Store removal from folders #22

orukaz opened this issue Oct 6, 2020 · 0 comments

Comments

@orukaz
Copy link

orukaz commented Oct 6, 2020

You have to make script to remove .DS_Store from directories. Here is my Laravel command that I included in my dev projects:

RemoveDSStore.php:

<?php

namespace RaidoOrumets\Base\Console\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Process\Process;

class RemoveDSStore extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'dsstore:remove {path? : Path (default: base_path}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Removes all the .DS_Store files from project';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $path = $this->argument('path') ?? base_path();
        $this->line($path);
        $process = Process::fromShellCommandline("find ". $path ." -name '*.DS_Store' -exec rm -r {} \;");

        // Start the process.
        $process->run();

        // Determine if the process failed.
        if (!$process->isSuccessful()) {
            // Handle process failure.
            $this->error('<fg=black;bg=red> ERROR </><bg=default> </> <fg=yellow;bg=red>.DS_Store</> cannot be removed!');
        } else {
            $this->info('<fg=black;bg=green> DONE </> All the <fg=yellow>.DS_store</> files are removed.');
        }
    }
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant