1
1
'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' ) ;
6
6
7
- var expectFilePath = common . isWindows ||
8
- common . isLinux ||
9
- common . isOSX ;
7
+ const expectFilePath = common . isWindows ||
8
+ common . isLinux ||
9
+ common . isOSX ;
10
10
11
- var watchSeenOne = 0 ;
12
- var watchSeenTwo = 0 ;
13
- var watchSeenThree = 0 ;
11
+ let watchSeenOne = 0 ;
12
+ let watchSeenTwo = 0 ;
13
+ let watchSeenThree = 0 ;
14
14
15
- var testDir = common . tmpDir ;
15
+ const testDir = common . tmpDir ;
16
16
17
- var filenameOne = 'watch.txt' ;
18
- var filepathOne = path . join ( testDir , filenameOne ) ;
17
+ const filenameOne = 'watch.txt' ;
18
+ const filepathOne = path . join ( testDir , filenameOne ) ;
19
19
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 ) ;
23
23
24
24
process . on ( 'exit' , function ( ) {
25
25
assert . ok ( watchSeenOne > 0 ) ;
@@ -33,12 +33,12 @@ fs.writeFileSync(filepathOne, 'hello');
33
33
34
34
assert . doesNotThrow (
35
35
function ( ) {
36
- var watcher = fs . watch ( filepathOne ) ;
36
+ const watcher = fs . watch ( filepathOne ) ;
37
37
watcher . on ( 'change' , function ( event , filename ) {
38
- assert . equal ( 'change' , event ) ;
38
+ assert . strictEqual ( 'change' , event ) ;
39
39
40
40
if ( expectFilePath ) {
41
- assert . equal ( 'watch.txt' , filename ) ;
41
+ assert . strictEqual ( 'watch.txt' , filename ) ;
42
42
}
43
43
watcher . close ( ) ;
44
44
++ watchSeenOne ;
@@ -57,11 +57,11 @@ fs.writeFileSync(filepathTwoAbs, 'howdy');
57
57
58
58
assert . doesNotThrow (
59
59
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 ) ;
62
62
63
63
if ( expectFilePath ) {
64
- assert . equal ( 'hasOwnProperty' , filename ) ;
64
+ assert . strictEqual ( 'hasOwnProperty' , filename ) ;
65
65
}
66
66
watcher . close ( ) ;
67
67
++ watchSeenTwo ;
@@ -79,13 +79,13 @@ const filepathThree = path.join(testsubdir, filenameThree);
79
79
80
80
assert . doesNotThrow (
81
81
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 ) ;
85
85
if ( expectFilePath ) {
86
- assert . equal ( 'newfile.txt' , filename ) ;
86
+ assert . strictEqual ( 'newfile.txt' , filename ) ;
87
87
} else {
88
- assert . equal ( null , filename ) ;
88
+ assert . strictEqual ( null , filename ) ;
89
89
}
90
90
watcher . close ( ) ;
91
91
++ watchSeenThree ;
@@ -94,7 +94,7 @@ assert.doesNotThrow(
94
94
) ;
95
95
96
96
setImmediate ( function ( ) {
97
- var fd = fs . openSync ( filepathThree , 'w' ) ;
97
+ const fd = fs . openSync ( filepathThree , 'w' ) ;
98
98
fs . closeSync ( fd ) ;
99
99
} ) ;
100
100
@@ -106,17 +106,17 @@ fs.watch(__filename, {persistent: false}, function() {
106
106
107
107
// whitebox test to ensure that wrapped FSEvent is safe
108
108
// https://github.com/joyent/node/issues/6690
109
- var oldhandle ;
109
+ let oldhandle ;
110
110
assert . throws ( function ( ) {
111
- var w = fs . watch ( __filename , function ( event , filename ) { } ) ;
111
+ const w = fs . watch ( __filename , function ( event , filename ) { } ) ;
112
112
oldhandle = w . _handle ;
113
113
w . _handle = { close : w . _handle . close } ;
114
114
w . close ( ) ;
115
115
} , TypeError ) ;
116
116
oldhandle . close ( ) ; // clean up
117
117
118
118
assert . throws ( function ( ) {
119
- var w = fs . watchFile ( __filename , { persistent : false } , function ( ) { } ) ;
119
+ const w = fs . watchFile ( __filename , { persistent : false } , function ( ) { } ) ;
120
120
oldhandle = w . _handle ;
121
121
w . _handle = { stop : w . _handle . stop } ;
122
122
w . stop ( ) ;
0 commit comments