Fix possible bug where if CoffeeScript starts with a shebang (hashbang) #!, then // gets put in front of it; but this is not a comment in CoffeeScript, so it causes a problem with the conversion.

1.2
IceArmy 2011-06-08 19:00:07 -07:00
parent 91ceec1e9b
commit 3c665681f4
2 changed files with 7 additions and 7 deletions

View File

@ -82,13 +82,13 @@ class Phantom(QObject):
do_action('PhantomInitPost', Bunch(locals()))
def execute(self):
if self.m_script.startswith('#!'):
self.m_script = '//' + self.m_script
if self.m_scriptFile.lower().endswith('.coffee'):
coffee = CSConverter(self)
self.m_script = coffee.convert(self.m_script)
if self.m_script.startswith('#!'):
self.m_script = '//' + self.m_script
self.m_page.mainFrame().evaluateJavaScript(self.m_script)
return not self.m_terminated

View File

@ -197,16 +197,16 @@ bool Phantom::execute()
m_script = QString::fromUtf8(file.readAll());
file.close();
if (m_script.startsWith("#!")) {
m_script.prepend("//");
}
if (m_scriptFile.endsWith(".coffee")) {
if (!m_converter)
m_converter = new CSConverter(this);
m_script = m_converter->convert(m_script);
}
if (m_script.startsWith("#!")) {
m_script.prepend("//");
}
m_page->mainFrame()->evaluateJavaScript(m_script);
return !m_terminated;
}