Skip to content

Commit dfadf9a

Browse files
committed
fix: 修改非git项目异常抛出
1 parent deec10c commit dfadf9a

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')) {
63+
$filesystem->copy(dirname(__DIR__) . '/Helper/.php_cs', $projectDir . '/.php_cs');
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';
68-
if (!file_exists($projectDir . '/.php_cs')) {
69-
$filesystem->copy(dirname(__DIR__) . '/Helper/.php_cs', $projectDir . '/.php_cs');
70-
}
7172
if (file_exists($hookDir . $fixFileName)) {
7273
return true;
7374
}

0 commit comments

Comments
 (0)