Skip to content

Commit

Permalink
Added the missing Compile File command.
Browse files Browse the repository at this point in the history
This was supposed to exist but didn't for some reason, see #9.
  • Loading branch information
Xavura committed Jul 18, 2012
1 parent 1900c55 commit 5e40d8e
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions CoffeeScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def run(cmd, args = [], source="", cwd = None, env = None):
if not type(args) is list:
args = [args]
if sys.platform == "win32":
if sys.platform == "win32":
proc = Popen([cmd]+args, env=env, cwd=cwd, stdout=PIPE, stdin=PIPE, stderr=PIPE, shell=True)
stat = proc.communicate(input=source)
else:
Expand All @@ -18,9 +18,9 @@ def run(cmd, args = [], source="", cwd = None, env = None):
if source == "":
command = [cmd]+args
else:
command = [cmd]+args+[source]
command = [cmd]+args+[source]
proc = Popen(command, env=env, cwd=cwd, stdout=PIPE, stderr=PIPE)
stat = proc.communicate()
stat = proc.communicate()
okay = proc.returncode == 0
return {"okay": okay, "out": stat[0], "err": stat[1]}

Expand Down Expand Up @@ -59,6 +59,20 @@ def get(view):
return text
return Text.all(view)

class CompileCommand(TextCommand):
def is_enabled(self):
return isCoffee(self.view)

def run(self, *args, **kwargs):
result = run("coffee", args=['-b', '-c', self.view.file_name()])

if result['okay'] is True:
status = 'Compilation Succeeded'
else:
status = 'Compilation Failed'

sublime.status_message(status)

class CompileAndDisplayCommand(TextCommand):
def is_enabled(self):
return isCoffee(self.view)
Expand Down Expand Up @@ -121,7 +135,7 @@ def finish(self, task):
cakepath = path.join(self.window.folders()[0], 'Cakefile')
if not path.exists(cakepath):
cakepath = path.dirname(self.window.active_view().file_name())

if not path.exists(cakepath):
return sublime.status_message("Cakefile not found.")

Expand Down

0 comments on commit 5e40d8e

Please sign in to comment.