Skip to content

Commit d2b7982

Browse files
author
James Halliday
committed
only turn on watches for middleware
1 parent 52824e8 commit d2b7982

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ var source = require('source');
88

99
exports = module.exports = function (opts) {
1010
var modified = new Date();
11-
var ee = opts.listen = new EventEmitter;
11+
12+
if (!opts.hasOwnProperty('watch')) opts.watch = true;
13+
var ee = opts.listen = opts.listen || new EventEmitter;
1214
var listening = false;
15+
1316
var srcCache = exports.bundle(opts);
1417

1518
return function (req, res, next) {
@@ -346,19 +349,19 @@ function unext (s) {
346349

347350
var watchedFiles = [];
348351
function fileWatch (file, opts) {
349-
if (opts.hasOwnProperty('watch') && !opts.watch) return;
352+
if (!opts.watch) return;
350353

351354
if (opts.listen) opts.listen.on('close', function () {
352355
fs.unwatchFile(file);
353356
});
354357

355358
watchedFiles.push(file);
356359
var wopts = {
357-
persistent : opts.watch && opts.watch.hasOwnProperty('persistent')
360+
persistent : opts.watch.hasOwnProperty('persistent')
358361
? opts.watch.persistent
359362
: true
360363
,
361-
interval : opts.watch && opts.watch.interval || 500,
364+
interval : opts.watch.interval || 500,
362365
};
363366

364367
fs.watchFile(file, wopts, function (curr, prev) {

0 commit comments

Comments
 (0)