Permalink
Browse files

Fix re-watching after npm install. Closes gh-479.

  • Loading branch information...
1 parent cc94cd7 commit 8f5f90fa86dd727ad0e7c2718502bb1efe460cfa @paulmillr paulmillr committed Apr 7, 2013
Showing with 14 additions and 6 deletions.
  1. +6 −3 src/helpers.coffee
  2. +8 −3 src/watch.coffee
View
@@ -3,6 +3,7 @@
{exec} = require 'child_process'
coffeescript = require 'coffee-script'
express = require 'express'
+http = require 'http'
fs = require 'fs'
os = require 'os'
sysPath = require 'path'
@@ -83,8 +84,9 @@ startDefaultServer = (port, path, base, callback) ->
server.use base, express.static path
server.all "#{base}/*", (request, response) ->
response.sendfile sysPath.join path, 'index.html'
- server.listen port, callback
- server
+ serv = http.createServer server
+ serv.listen port, callback
+ serv
exports.startServer = (config, callback = (->)) ->
port = parseInt config.server.port, 10
@@ -322,9 +324,10 @@ exports.loadConfig = (configPath = 'config', options = {}) ->
fullPath = sysPath.resolve configPath
delete require.cache[fullPath]
try
- {config} = require fullPath
+ originalConfig = require(fullPath).config
catch error
throw new Error("couldn\'t load config #{configPath}. #{error}")
+ config = extend {}, originalConfig
setConfigDefaults config, configPath
deprecations = getConfigDeprecations config
deprecations.forEach logger.warn if deprecations.length > 0
View
@@ -155,9 +155,14 @@ getCompileFn = (config, joinConfig, fileList, minifiers, watcher, callback) -> (
# Returns Function.
getReloadFn = (config, options, onCompile, watcher, server) -> (reInstall) ->
reWatch = ->
- server?.close?()
- watcher.close()
- watch(config.persistent, options, onCompile)
+ restart = ->
+ watcher.close()
+ watch config.persistent, options, onCompile
+ if server?.close?
+ server.close restart
+ else
+ restart()
+
if reInstall
helpers.install config.paths.root, reWatch
else

0 comments on commit 8f5f90f

Please sign in to comment.