forked from ChinaGodMan/UserScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy_js_files.py
More file actions
21 lines (21 loc) · 966 Bytes
/
Copy pathcopy_js_files.py
File metadata and controls
21 lines (21 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
import subprocess
import json
target_dir = '.'
result = subprocess.run(['git', 'diff', '--name-only', 'HEAD^', 'HEAD'], capture_output=True, text=True)
changed_files = result.stdout.splitlines()
with open('docs/ScriptsPath.json', 'r', encoding='utf-8') as json_file:
scripts_data = json.load(json_file)
for file in changed_files:
if file.endswith('.js'):
file_path = os.path.join(os.getcwd(), file)
if os.path.exists(file_path):
file_name = os.path.basename(file)
found = any(script['path'] == file_name for script in scripts_data['scripts'])
if not found:
print(f'文件 {file_name} 在 JSON 中找不到,跳过操作。')
continue
target_path = os.path.join(target_dir, file_name)
subprocess.run(['node', 'utils/single-format-monkey-meta.js', file_path], check=True)
else:
print(f'文件 {file} 不存在,跳过')