Skip to content

Commit 9439a48

Browse files
committed
refactor: change owner config json
1 parent 73e9004 commit 9439a48

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/Commands/ChangeOwnerConfigJson.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,27 @@ public function handle(): void
3535
return;
3636
}
3737

38-
$user = $this->argument('user');
38+
$user = $this->argument('user') ?? $this->getDefaultUserGroup();
3939
$group = $this->argument('group') ?? $user;
4040

41-
if (!is_string($user) || !is_string($group)) {
41+
if (empty($user) || empty($group)) {
4242
$user = $group = $this->getDefaultUserGroup();
4343
}
4444

45+
$this->changeOwner($user, $group);
46+
}
47+
48+
/**
49+
* @param string $user
50+
* @param string $group
51+
*
52+
* @return void
53+
*/
54+
private function changeOwner(string $user, string $group): void
55+
{
4556
$jsonsPath = config('telegram-git-notifier.data_file.storage_folder');
4657
if (is_string($jsonsPath) && file_exists($jsonsPath)) {
47-
shell_exec("chown -R ".escapeshellarg($user).":".escapeshellarg($group)." ".escapeshellarg($jsonsPath));
58+
shell_exec('chown -R '.escapeshellarg($user).':'.escapeshellarg($group).' '.escapeshellarg($jsonsPath));
4859
} else {
4960
$this->error('The path to the jsons folder is not valid');
5061
}

0 commit comments

Comments
 (0)