Skip to content

Commit 1d5bedd

Browse files
committed
chore: upgrade packages
1 parent b01144d commit 1d5bedd

File tree

3 files changed

+38
-39
lines changed

3 files changed

+38
-39
lines changed

package-lock.json

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"devDependencies": {
1111
"@commitlint/cli": "^17.6.5",
1212
"@commitlint/config-conventional": "^17.6.5",
13-
"@prettier/plugin-php": "^0.19.5",
13+
"@prettier/plugin-php": "^0.19.6",
1414
"husky": "^8.0.3",
1515
"lint-staged": "^13.2.2",
1616
"prettier": "^2.8.8"

run_format.py

+28-29
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,28 @@ def prettier_format():
1010
command = f'npx prettier --write "**/*.{suffix}"'
1111
os.system(command)
1212

13+
# format php code
14+
for root, _, files in os.walk(path):
15+
for name in files:
16+
if name.endswith('.php'):
17+
p1 = root + '/' + name
18+
with open(p1, 'r', encoding='utf-8') as f:
19+
content = f.read()
20+
content = '<?php\n' + content
21+
with open(p1, 'w', encoding='utf-8') as f:
22+
f.write(content)
23+
command = 'npx prettier --write "**/*.php"'
24+
os.system(command)
25+
for root, _, files in os.walk(path):
26+
for name in files:
27+
if name.endswith('.php'):
28+
p1 = root + '/' + name
29+
with open(p1, 'r', encoding='utf-8') as f:
30+
content = f.read()
31+
content = content.replace('<?php\n', '')
32+
with open(p1, 'w', encoding='utf-8') as f:
33+
f.write(content)
34+
1335

1436
def clang_format():
1537
"""Format code with clang-format"""
@@ -49,7 +71,8 @@ def clang_format():
4971
os.remove(p2)
5072

5173

52-
def format_py():
74+
def black_format():
75+
"""Format python code with black"""
5376
command = 'black -S .'
5477
os.system(command)
5578

@@ -60,7 +83,7 @@ def format_py():
6083
with open(p1, 'r', encoding='utf-8') as f:
6184
content = f.read()
6285
x = content
63-
res = re.findall(f'```python\n(.*?)```', content, re.S)
86+
res = re.findall('```python\n(.*?)```', content, re.S)
6487
if not res:
6588
continue
6689
print(p1)
@@ -77,38 +100,14 @@ def format_py():
77100
os.remove(p2)
78101

79102

80-
def format_php():
81-
for root, _, files in os.walk(path):
82-
for name in files:
83-
if name.endswith('.php'):
84-
p1 = root + '/' + name
85-
with open(p1, 'r', encoding='utf-8') as f:
86-
content = f.read()
87-
content = '<?php\n' + content
88-
with open(p1, 'w', encoding='utf-8') as f:
89-
f.write(content)
90-
command = f'npx prettier --write "**/*.php"'
91-
os.system(command)
92-
for root, _, files in os.walk(path):
93-
for name in files:
94-
if name.endswith('.php'):
95-
p1 = root + '/' + name
96-
with open(p1, 'r', encoding='utf-8') as f:
97-
content = f.read()
98-
content = content.replace('<?php\n', '')
99-
with open(p1, 'w', encoding='utf-8') as f:
100-
f.write(content)
101-
102-
103103
def git_add():
104104
"""Git add all files"""
105105
command = 'git add .'
106106
os.system(command)
107107

108108

109109
if __name__ == '__main__':
110+
prettier_format()
111+
black_format()
110112
# clang_format()
111-
# prettier_format()
112-
# format_py()
113-
# git_add()
114-
format_php()
113+
git_add()

0 commit comments

Comments
 (0)