Skip to content

Commit 476d266

Browse files
committed
fix: 修改非git项目异常抛出
1 parent 2aeea00 commit 476d266

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/Plugin/Plugin.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,16 @@ public function installGitPreHook() {
5959
$config = $this->composer->getConfig();
6060
$filesystem = new Filesystem();
6161
$projectDir = dirname($filesystem->normalizePath(realpath(realpath($config->get('vendor-dir')))));
62+
if (!file_exists($projectDir . '/.php-cs-fixer.php')) {
63+
$filesystem->copy(dirname(__DIR__) . '/Helper/.php-cs-fixer.php', $projectDir . '/.php-cs-fixer.php');
64+
}
65+
6266
$hookDir = $projectDir . '/.git/hooks/';
6367
if (!file_exists($hookDir)) {
64-
throw new \Exception('not a git project');
68+
return true;
6569
}
6670

6771
$fixFileName = 'pre-commit-cs-fix-30';
68-
if (!file_exists($projectDir . '/.php-cs-fixer.php')) {
69-
$filesystem->copy(dirname(__DIR__) . '/Helper/.php-cs-fixer.php', $projectDir . '/.php-cs-fixer.php');
70-
}
7172
if (file_exists($hookDir . $fixFileName)) {
7273
return true;
7374
}

0 commit comments

Comments
 (0)