Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
Fix re-watching after npm install. Closes gh-479.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Apr 7, 2013
1 parent cc94cd7 commit 8f5f90f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/helpers.coffee
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions src/watch.coffee
Expand Up @@ -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
Expand Down

0 comments on commit 8f5f90f

Please sign in to comment.