diff --git a/bin/watch/get-watch-config.js b/bin/watch/get-watch-config.js index f69072f..2220228 100644 --- a/bin/watch/get-watch-config.js +++ b/bin/watch/get-watch-config.js @@ -26,7 +26,6 @@ module.exports = ({ cli, filepkg }) => { const watchConfig = { usePolling, ignoreInitial: true, - cwd: process.cwd(), ignored } diff --git a/bin/watch/index.js b/bin/watch/index.js index 92ac53e..c2743e5 100644 --- a/bin/watch/index.js +++ b/bin/watch/index.js @@ -3,6 +3,7 @@ const getTimestamp = require('time-stamp') const logSymbols = require('log-symbols') const { watch } = require('chokidar') +const debounce = require('debounce') const chalk = require('chalk') const destroySockets = require('./destroy-sockets') @@ -30,8 +31,10 @@ module.exports = ({ filename, filepkg, server, cli, sockets }) => { server.close(restartServer.bind(this, { filename, filepkg, cli, watcher })) } - watcher.on('all', (event, filename) => - doRestart({ filename, forcing: false }) + watcher.on( + 'all', + debounce((event, filename) => doRestart({ filename, forcing: false })), + 10 ) if (!isListenRestart) { diff --git a/package.json b/package.json index 874bfd5..b90d79e 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "chalk": "~2.1.0", "chokidar": "~1.7.0", "clear-module": "~2.1.0", + "debounce": "~1.0.2", "get-port": "~3.1.0", "ignore-by-default": "~1.0.1", "ignored": "~2.0.4",