Skip to content

Commit

Permalink
fix: properly pass options to chokidar
Browse files Browse the repository at this point in the history
  • Loading branch information
dnohales authored and remy committed Aug 29, 2018
1 parent b8ff6b4 commit 5a47a32
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/monitor/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function watch() {

var watcher = chokidar.watch(
dirs,
Object.assign({}, watchOptions, config.watchOptions || {})
Object.assign({}, watchOptions, config.options.watchOptions || {})
);

watcher.ready = false;
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/configs/watch-options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ext": "json,js,html",
"watchOptions": {
"awaitWriteFinish": true
}
}
29 changes: 29 additions & 0 deletions test/monitor/watch.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use-strict';

var assert = require('assert');
var chokidar = require('chokidar');
var process = require('process');
var config = require('../../lib/config');
var watch = require('../../lib/monitor/watch');

describe('watch', function() {
it('should pass watchOptions to the watcher', function(done) {
process.chdir(process.cwd() + '/test/fixtures/configs');

var passedOptions = {};
var originalWatch = chokidar.watch;
chokidar.watch = function(dirs, options) {
passedOptions = options;
return originalWatch(dirs, options);
};

config.load({
configFile: process.cwd() + '/watch-options.json'
}, () => {
watch.watch();
chokidar.watch = originalWatch;
assert(passedOptions.awaitWriteFinish, 'awaitWriteFinish does not have the correct value');
done();
});
});
})

0 comments on commit 5a47a32

Please sign in to comment.