Skip to content
This repository has been archived by the owner on Feb 12, 2018. It is now read-only.

Commit

Permalink
Run coffeescripts directly
Browse files Browse the repository at this point in the history
  • Loading branch information
dmfrancisco committed Jul 14, 2011
1 parent a342093 commit d26fd96
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -9,9 +9,9 @@
"main": "web.js",
"preferGlobal": true,
"bin": {
"escrito": "web.js"
"escrito": "web.coffee"
},
"scripts": { "start": "node web.js" },
"scripts": { "start": "coffee web.coffee" },
"config" : {
"port" : "3000",
"database" : "memory"
Expand Down
18 changes: 13 additions & 5 deletions web.coffee
@@ -1,4 +1,12 @@
#!/usr/bin/env node
#!/usr/bin/env coffee

# Try also to require locally (this is a known coffeescript bug - http://github.com/jashkenas/coffee-script/issues/1035)
requireModule = (filename) ->
try
require(filename)
catch error
require("#{__dirname}/node_modules/#{filename}")


# Processing the command line parameters
opt = require('optimist')
Expand Down Expand Up @@ -51,17 +59,17 @@ runServer = (argv, sharejs, connect, sys, crypto) ->
sys.puts "Escrito is running at http://localhost:#{argv.p}/"


connect = require('connect')
connect = requireModule('connect')
crypto = requireModule('crypto')
sys = require('sys')
crypto = require('crypto')

try
sharejs = require('share').server
sharejs = requireModule('share').server
runServer(opt.argv)
catch error
# Build ShareJS (this is not currently done automatically by ShareJS)
exec = require('child_process').exec
exec "cd #{__dirname} && cake build-dependencies", (err, stdout, stderr) ->
throw err if err
sharejs = require('share').server
sharejs = requireModule('share').server
runServer(opt.argv, sharejs, connect, sys, crypto)

0 comments on commit d26fd96

Please sign in to comment.