Skip to content

Commit

Permalink
Add connect server
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Dec 12, 2010
1 parent 08b6fb5 commit f0cee21
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
23 changes: 22 additions & 1 deletion lib/stitch/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 17 additions & 5 deletions src/stitch/index.coffee
@@ -1,7 +1,8 @@
_ = require 'underscore'
async = require 'async'
fs = require 'fs'
sys = require 'sys'
_ = require 'underscore'
async = require 'async'
connect = require 'connect'
fs = require 'fs'
sys = require 'sys'

{extname, join, normalize} = require 'path'

Expand All @@ -28,7 +29,6 @@ exports.Package = class Package
@mtimeCache = {}
@compileCache = {}


compile: (callback) ->
async.reduce @paths, {}, @gatherSourcesFromPath.bind(@), (err, sources) =>
return callback err if err
Expand Down Expand Up @@ -65,6 +65,18 @@ exports.Package = class Package

callback err, result

createServer: ->
connect.createServer (req, res, next) =>
@compile (err, source) ->
if err
sys.debug "#{err.stack}"
message = "" + err.stack
res.writeHead 500, 'Content-Type': 'text/javascript'
res.end "throw #{JSON.stringify(message)}"
else
res.writeHead 200, 'Content-Type': 'text/javascript'
res.end source


gatherSourcesFromPath: (sources, sourcePath, callback) ->
fs.stat sourcePath, (err, stat) =>
Expand Down

0 comments on commit f0cee21

Please sign in to comment.