@@ -1765,4 +1765,61 @@ function runTests(baseopts) {
1765
1765
} ) ;
1766
1766
} ) ;
1767
1767
} ) ;
1768
+ describe ( 'env variable option override' , function ( ) {
1769
+ describe ( 'CHOKIDAR_USEPOLLING' , function ( ) {
1770
+ afterEach ( function ( ) {
1771
+ delete process . env . CHOKIDAR_USEPOLLING ;
1772
+ } ) ;
1773
+
1774
+ it ( 'should make options.usePolling `true` when CHOKIDAR_USEPOLLING is set to true' , function ( done ) {
1775
+ options . usePolling = false ;
1776
+ process . env . CHOKIDAR_USEPOLLING = true ;
1777
+
1778
+ watcher = chokidar . watch ( fixturesPath , options ) . on ( 'ready' , function ( ) {
1779
+ watcher . options . usePolling . should . be . true ;
1780
+ done ( ) ;
1781
+ } ) ;
1782
+ } ) ;
1783
+
1784
+ it ( 'should make options.usePolling `true` when CHOKIDAR_USEPOLLING is set to 1' , function ( done ) {
1785
+ options . usePolling = false ;
1786
+ process . env . CHOKIDAR_USEPOLLING = 1 ;
1787
+
1788
+ watcher = chokidar . watch ( fixturesPath , options ) . on ( 'ready' , function ( ) {
1789
+ watcher . options . usePolling . should . be . true ;
1790
+ done ( ) ;
1791
+ } ) ;
1792
+ } ) ;
1793
+
1794
+ it ( 'should make options.usePolling `false` when CHOKIDAR_USEPOLLING is set to false' , function ( done ) {
1795
+ options . usePolling = true ;
1796
+ process . env . CHOKIDAR_USEPOLLING = false ;
1797
+
1798
+ watcher = chokidar . watch ( fixturesPath , options ) . on ( 'ready' , function ( ) {
1799
+ watcher . options . usePolling . should . be . false ;
1800
+ done ( ) ;
1801
+ } ) ;
1802
+ } ) ;
1803
+
1804
+ it ( 'should make options.usePolling `false` when CHOKIDAR_USEPOLLING is set to 0' , function ( done ) {
1805
+ options . usePolling = true ;
1806
+ process . env . CHOKIDAR_USEPOLLING = false ;
1807
+
1808
+ watcher = chokidar . watch ( fixturesPath , options ) . on ( 'ready' , function ( ) {
1809
+ watcher . options . usePolling . should . be . false ;
1810
+ done ( ) ;
1811
+ } ) ;
1812
+ } ) ;
1813
+
1814
+ it ( 'should not attenuate options.usePolling when CHOKIDAR_USEPOLLING is set to an arbitrary value' , function ( done ) {
1815
+ options . usePolling = true ;
1816
+ process . env . CHOKIDAR_USEPOLLING = 'foo' ;
1817
+
1818
+ watcher = chokidar . watch ( fixturesPath , options ) . on ( 'ready' , function ( ) {
1819
+ watcher . options . usePolling . should . be . true ;
1820
+ done ( ) ;
1821
+ } ) ;
1822
+ } ) ;
1823
+ } ) ;
1824
+ } ) ;
1768
1825
}
0 commit comments