Skip to content

Commit 2442f7b

Browse files
YAmikepes128
authored andcommitted
Added ability to force interval value by setting `CHOKIDAR_INTERVAL… (#557)
* Added ability to force `interval` value by setting `CHOKIDAR_INTERVAL` env variable. * Parse to integer. * Simply if (envInterval) should be fine in this case, since we're not contending with false as a valid potential value. * Combine lines.
1 parent 0faec86 commit 2442f7b

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
* Added ability to force `interval` value by setting `CHOKIDAR_INTERVAL`
2+
env variable
3+
14
# Chokidar 1.6.0 (Jun 22, 2016)
25
* Added ability for force `usePolling` mode by setting `CHOKIDAR_USEPOLLING`
36
env variable

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ non-standard situations. Setting to `true` explicitly on OS X overrides the
183183
`useFsEvents` default. You may also set the CHOKIDAR_USEPOLLING env variable
184184
to true (1) or false (0) in order to override this option.
185185
* _Polling-specific settings_ (effective when `usePolling: true`)
186-
* `interval` (default: `100`). Interval of file system polling.
186+
* `interval` (default: `100`). Interval of file system polling. You may also
187+
set the CHOKIDAR_INTERVAL env variable to override this option.
187188
* `binaryInterval` (default: `300`). Interval of file system
188189
polling for binary files.
189190
([see list of binary extensions](https://github.com/sindresorhus/binary-extensions/blob/master/binary-extensions.json))

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ function FSWatcher(_opts) {
105105
opts.usePolling = !!envLower
106106
}
107107
}
108+
var envInterval = process.env.CHOKIDAR_INTERVAL;
109+
if (envInterval) {
110+
opts.interval = parseInt(envInterval);
111+
}
108112

109113
// Editor atomic write normalization enabled by default with fs.watch
110114
if (undef('atomic')) opts.atomic = !opts.usePolling && !opts.useFsEvents;

test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,5 +1877,20 @@ function runTests(baseopts) {
18771877
});
18781878
});
18791879
});
1880+
describe('CHOKIDAR_INTERVAL', function() {
1881+
afterEach(function() {
1882+
delete process.env.CHOKIDAR_INTERVAL;
1883+
});
1884+
1885+
it('should make options.interval = CHOKIDAR_INTERVAL when it is set', function(done) {
1886+
options.interval = 100;
1887+
process.env.CHOKIDAR_INTERVAL = 1500;
1888+
1889+
watcher = chokidar.watch(fixturesPath, options).on('ready', function() {
1890+
watcher.options.interval.should.be.equal(1500);
1891+
done();
1892+
});
1893+
});
1894+
});
18801895
});
18811896
}

0 commit comments

Comments
 (0)