forked from lennart/sublime-node-mocha
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDetectMochaTest.py
More file actions
24 lines (19 loc) · 765 Bytes
/
DetectMochaTest.py
File metadata and controls
24 lines (19 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import sublime, sublime_plugin
import os
class MochaDetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects test files written in js"""
""" Modified for Mocha tests and Sublime Text 2 """
""" Original Gist for Rails here: https://gist.github.com/925008 """
def on_load(self, view):
filename = view.file_name()
if not filename: # buffer has never been saved
return
name = os.path.basename(filename.lower())
dirname = os.path.dirname(filename.lower())
if dirname[-4:] == "test":
set_syntax(view, "Mocha", "Mocha")
def set_syntax(view, syntax, path=None):
if path is None:
path = syntax
view.settings().set('syntax', 'Packages/'+ path + '/' + syntax + '.tmLanguage')
print "Switched syntax to: " + syntax