diff --git a/README.md b/README.md index 7704e73..7b5a773 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,7 @@ $ svr -i .cache -i public ## Tips -### Development Server +### Main file This could be a good start point for a HTTP server: diff --git a/bin/watch/index.js b/bin/watch/index.js index e755855..17d9413 100644 --- a/bin/watch/index.js +++ b/bin/watch/index.js @@ -23,6 +23,7 @@ const doRestart = ({ ignored, sockets, server, + filename, filepath, pkg, pwd, @@ -32,7 +33,6 @@ const doRestart = ({ watcher, port }) => { - const filename = path.basename(filepath) const spinner = logRestart({ filename, forcing }) destroySockets(sockets) server.close( @@ -69,12 +69,13 @@ module.exports = ({ const toWatch = [].concat(watchFiles, pwd) const watcher = watch(toWatch, watchConfig) - const restart = ({ forcing }) => + const restart = ({ forcing, filename }) => doRestart({ watchFiles, ignored, sockets, server, + filename, filepath, pwd, pkg, @@ -85,8 +86,11 @@ module.exports = ({ watcher.once( 'all', - debounce((event, filename) => restart({ forcing: false })), - 10 + debounce( + (event, filename) => + restart({ forcing: false, filename: path.relative(pwd, filename) }), + 10 + ) ) if (!firsTime) {