11'use strict' ;
2- var common = require ( '../common' ) ;
3- var assert = require ( 'assert' ) ;
4- var path = require ( 'path' ) ;
5- var fs = require ( 'fs' ) ;
2+ const common = require ( '../common' ) ;
3+ const assert = require ( 'assert' ) ;
4+ const path = require ( 'path' ) ;
5+ const fs = require ( 'fs' ) ;
66
7- var expectFilePath = common . isWindows ||
8- common . isLinux ||
9- common . isOSX ;
7+ const expectFilePath = common . isWindows ||
8+ common . isLinux ||
9+ common . isOSX ;
1010
11- var watchSeenOne = 0 ;
12- var watchSeenTwo = 0 ;
13- var watchSeenThree = 0 ;
11+ let watchSeenOne = 0 ;
12+ let watchSeenTwo = 0 ;
13+ let watchSeenThree = 0 ;
1414
15- var testDir = common . tmpDir ;
15+ const testDir = common . tmpDir ;
1616
17- var filenameOne = 'watch.txt' ;
18- var filepathOne = path . join ( testDir , filenameOne ) ;
17+ const filenameOne = 'watch.txt' ;
18+ const filepathOne = path . join ( testDir , filenameOne ) ;
1919
20- var filenameTwo = 'hasOwnProperty' ;
21- var filepathTwo = filenameTwo ;
22- var filepathTwoAbs = path . join ( testDir , filenameTwo ) ;
20+ const filenameTwo = 'hasOwnProperty' ;
21+ const filepathTwo = filenameTwo ;
22+ const filepathTwoAbs = path . join ( testDir , filenameTwo ) ;
2323
2424process . on ( 'exit' , function ( ) {
2525 assert . ok ( watchSeenOne > 0 ) ;
@@ -33,12 +33,12 @@ fs.writeFileSync(filepathOne, 'hello');
3333
3434assert . doesNotThrow (
3535 function ( ) {
36- var watcher = fs . watch ( filepathOne ) ;
36+ const watcher = fs . watch ( filepathOne ) ;
3737 watcher . on ( 'change' , function ( event , filename ) {
38- assert . equal ( 'change' , event ) ;
38+ assert . strictEqual ( 'change' , event ) ;
3939
4040 if ( expectFilePath ) {
41- assert . equal ( 'watch.txt' , filename ) ;
41+ assert . strictEqual ( 'watch.txt' , filename ) ;
4242 }
4343 watcher . close ( ) ;
4444 ++ watchSeenOne ;
@@ -57,11 +57,11 @@ fs.writeFileSync(filepathTwoAbs, 'howdy');
5757
5858assert . doesNotThrow (
5959 function ( ) {
60- var watcher = fs . watch ( filepathTwo , function ( event , filename ) {
61- assert . equal ( 'change' , event ) ;
60+ const watcher = fs . watch ( filepathTwo , function ( event , filename ) {
61+ assert . strictEqual ( 'change' , event ) ;
6262
6363 if ( expectFilePath ) {
64- assert . equal ( 'hasOwnProperty' , filename ) ;
64+ assert . strictEqual ( 'hasOwnProperty' , filename ) ;
6565 }
6666 watcher . close ( ) ;
6767 ++ watchSeenTwo ;
@@ -79,13 +79,13 @@ const filepathThree = path.join(testsubdir, filenameThree);
7979
8080assert . doesNotThrow (
8181 function ( ) {
82- var watcher = fs . watch ( testsubdir , function ( event , filename ) {
83- var renameEv = common . isSunOS ? 'change' : 'rename' ;
84- assert . equal ( renameEv , event ) ;
82+ const watcher = fs . watch ( testsubdir , function ( event , filename ) {
83+ const renameEv = common . isSunOS ? 'change' : 'rename' ;
84+ assert . strictEqual ( renameEv , event ) ;
8585 if ( expectFilePath ) {
86- assert . equal ( 'newfile.txt' , filename ) ;
86+ assert . strictEqual ( 'newfile.txt' , filename ) ;
8787 } else {
88- assert . equal ( null , filename ) ;
88+ assert . strictEqual ( null , filename ) ;
8989 }
9090 watcher . close ( ) ;
9191 ++ watchSeenThree ;
@@ -94,7 +94,7 @@ assert.doesNotThrow(
9494) ;
9595
9696setImmediate ( function ( ) {
97- var fd = fs . openSync ( filepathThree , 'w' ) ;
97+ const fd = fs . openSync ( filepathThree , 'w' ) ;
9898 fs . closeSync ( fd ) ;
9999} ) ;
100100
@@ -106,17 +106,17 @@ fs.watch(__filename, {persistent: false}, function() {
106106
107107// whitebox test to ensure that wrapped FSEvent is safe
108108// https://github.com/joyent/node/issues/6690
109- var oldhandle ;
109+ let oldhandle ;
110110assert . throws ( function ( ) {
111- var w = fs . watch ( __filename , function ( event , filename ) { } ) ;
111+ const w = fs . watch ( __filename , function ( event , filename ) { } ) ;
112112 oldhandle = w . _handle ;
113113 w . _handle = { close : w . _handle . close } ;
114114 w . close ( ) ;
115115} , TypeError ) ;
116116oldhandle . close ( ) ; // clean up
117117
118118assert . throws ( function ( ) {
119- var w = fs . watchFile ( __filename , { persistent : false } , function ( ) { } ) ;
119+ const w = fs . watchFile ( __filename , { persistent : false } , function ( ) { } ) ;
120120 oldhandle = w . _handle ;
121121 w . _handle = { stop : w . _handle . stop } ;
122122 w . stop ( ) ;
0 commit comments