Skip to content

Commit deec10c

Browse files
committed
style: 优化代码
1 parent 953a731 commit deec10c

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/Helper/pre-commit-cs-fix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ CHANGED_FILES=$(git diff --cached --name-only --diff-filter=ACM -- '*.php')
1616
echo $CHANGED_FILES
1717

1818
if [ -n "$CHANGED_FILES" ]; then
19-
$PHP_CS_FIXER --config=.php_cs --verbose fix $CHANGED_FILES;
19+
$PHP_CS_FIXER --config=$PHP_CS_CONFIG --verbose fix $CHANGED_FILES;
2020
git add $CHANGED_FILES;
2121
fi
2222

src/Plugin/Plugin.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,21 @@ public function installGitPreHook() {
6464
throw new \Exception('not a git project');
6565
}
6666

67+
$fixFileName = 'pre-commit-cs-fix';
6768
if (!file_exists($projectDir . '/.php_cs')) {
6869
$filesystem->copy(dirname(__DIR__) . '/Helper/.php_cs', $projectDir . '/.php_cs');
6970
}
70-
if (file_exists($hookDir . 'pre-commit-cs-fix')) {
71+
if (file_exists($hookDir . $fixFileName)) {
7172
return true;
7273
}
7374

74-
$filesystem->copy(dirname(__DIR__) . '/Helper/pre-commit-cs-fix', $hookDir . 'pre-commit-cs-fix');
75-
$list[] = $hookDir . 'pre-commit-cs-fix';
75+
$filesystem->copy(dirname(__DIR__) . '/Helper/pre-commit-cs-fix', $hookDir . $fixFileName);
76+
$list[] = $hookDir . $fixFileName;
7677

7778
if (file_exists($hookDir . 'pre-commit')) {
78-
file_put_contents($hookDir . 'pre-commit', "\n exec " . $hookDir . 'pre-commit-cs-fix', FILE_APPEND);
79+
file_put_contents($hookDir . 'pre-commit', "\n exec " . $hookDir . $fixFileName, FILE_APPEND);
7980
} else {
80-
file_put_contents($hookDir . 'pre-commit', "#!/bin/bash \n exec " . $hookDir . 'pre-commit-cs-fix');
81+
file_put_contents($hookDir . 'pre-commit', "#!/bin/bash \n exec " . $hookDir . $fixFileName);
8182
$list[] = $hookDir . 'pre-commit';
8283
}
8384
$this->changePermission($list);

0 commit comments

Comments
 (0)