-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphpcs.py
37 lines (32 loc) · 908 Bytes
/
phpcs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sublime
import sublime_plugin
import os
import os.path
import threading
class PhpcsCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view;
fileName = view.file_name();
suffix = os.path.splitext(fileName)[1][1:]
if suffix == 'php':
fix(fileName)
def fix(phpFile):
if not os.path.exists(phpFile):
return;
command = "phpcs fix " + phpFile;
os.system(command);
'''
class AutoAlign(sublime_plugin.EventListener):
def on_post_save(self, view):
thread = HandlerThread(view)
thread.start()
'''
class HandlerThread(threading.Thread):
def __init__(self, view):
self.view = view
threading.Thread.__init__(self)
def run(self):
fileName = self.view.file_name();
suffix = os.path.splitext(fileName)[1][1:]
if suffix == 'php':
fix(fileName)