Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Coffee support #15

Open
wants to merge 1 commit into from

1 participant

@bragi

Hi Tim,

As promised a patch bringing coffee script support for spark. There are two parts:

When coffee-script is required it patches 'require' to look for .coffee files as well. When no coffee-script is available we ignore it silently.

Second part is trivial: when coffee-script is available check if {app,server}.coffee is available in addition to it's .js counterpart and require it via node built-in (and extended by coffee-script) mechanism.

BTW: standardizing on a single entry point (either one is good, app.{js,coffee} is my preferred one) may be a good idea.

Ł.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 4, 2010
  1. @bragi
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 0 deletions.
  1. +13 −0 bin/spark
View
13 bin/spark
@@ -21,6 +21,13 @@ var child_process = require('child_process'),
net = require('net');
/**
+ * Coffee script support
+ * Try to require coffee script, ignore if it fails.
+ */
+var coffee_script;
+try { coffee_script = require('coffee-script') } catch (e) {}
+
+/**
* Framework version.
*/
@@ -253,6 +260,12 @@ function getAppPath() {
} else if (exists(path + 'server.js')) {
log('detected server.js');
path += 'server';
+ } else if (coffee_script && exists(path + 'app.coffee')) {
+ log('detected app.coffee');
+ path += 'app';
+ } else if (coffee_script && exists(path + 'server.coffee')) {
+ log('detected server.coffee');
+ path += 'server';
} else {
abort('app not found, pass a module path, or create {app,server}.js');
}
Something went wrong with that request. Please try again.