Skip to content

Commit

Permalink
can now pass in own http server
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneware committed Jul 6, 2012
1 parent f670f58 commit b53e2c4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/livereload.coffee
Expand Up @@ -109,7 +109,7 @@ exports.createServer = (config) ->
res.writeHead(200, {'Content-Type': 'text/javascript'})
res.end fs.readFileSync __dirname + '/../ext/livereload.js'

config.server = app
config.server ?= app

server = new Server config
server.listen()
Expand Down
6 changes: 4 additions & 2 deletions lib/livereload.js

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

16 changes: 16 additions & 0 deletions test/index.test.coffee
Expand Up @@ -17,3 +17,19 @@ describe 'livereload http file servingt', ->
server.config.server.close()

done()
it 'should allow you to override the internal http server', (done) ->
app = http.createServer (req, res) ->
if url.parse(req.url).pathname is '/livereload.js'
res.writeHead(200, {'Content-Type': 'text/javascript'})
res.end '// nothing to see here'

server = livereload.createServer({port: 35729, server: app})

request 'http://localhost:35729/livereload.js?snipver=1', (error, response, body) ->
should.not.exist error
response.statusCode.should.equal 200
body.should.equal '// nothing to see here'

server.config.server.close()

done()

0 comments on commit b53e2c4

Please sign in to comment.