Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"beberlei/assert": "~2.7",
"bruli/php-value-objects": "~0.1",
"bruli/event-bus-bundle": "^0.5",
"symfony/flex": "~1.0"
"symfony/flex": "~1.0",
"symfony/process": "^4.0|^5.0"
},
"require-dev": {
"fzaninotto/faker": "^1.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,33 @@ public function copyPrepareCommitMsgHook(): void

protected function hookExists(string $hookFile): bool
{
return file_exists(sprintf('%s%s', $this->hooksDir, $hookFile));
return \file_exists($this->hooksDir . "/$hookFile");
}

protected function copyFile(string $hookFile): void
{
$copy = new Process(sprintf("mkdir -p {$this->hooksDir} && cp %s %s", $hookFile, $this->hooksDir));
$this->createHooksDir();

$copy = new Process(['cp', $hookFile, $this->hooksDir]);
$copy->run();
}

protected function createHooksDir(): void
{
$mkdir = new Process(['mkdir', '-p', $this->hooksDir]);
$mkdir->run();
}

protected function setPermissions(string $hookFile): void
{
$permissions = new Process(sprintf('chmod 775 %s%s', $this->hooksDir, $hookFile));
$permissions = new Process(['chmod', '775', $this->hooksDir . "/$hookFile"]);
$permissions->run();
}

protected function copyHookFile(string $file): void
{
if (false === $this->hookExists($file)) {
$this->copyFile(sprintf('%s/%s', $this->sourceHooksDir, $file));
$this->copyFile($this->sourceHooksDir . "/$file");
$this->setPermissions($file);
}
}
Expand Down