@ -1,25 +1,25 @@
'use strict' ;
var common = require ( '../common' ) ;
var assert = require ( 'assert' ) ;
var path = require ( 'path' ) ;
var fs = require ( 'fs' ) ;
const common = require ( '../common' ) ;
const assert = require ( 'assert' ) ;
const path = require ( 'path' ) ;
const fs = require ( 'fs' ) ;
var expectFilePath = common . isWindows ||
common . isLinux ||
common . isOSX ;
const expectFilePath = common . isWindows ||
common . isLinux ||
common . isOSX ;
var watchSeenOne = 0 ;
var watchSeenTwo = 0 ;
var watchSeenThree = 0 ;
let watchSeenOne = 0 ;
let watchSeenTwo = 0 ;
let watchSeenThree = 0 ;
var testDir = common . tmpDir ;
const testDir = common . tmpDir ;
var filenameOne = 'watch.txt' ;
var filepathOne = path . join ( testDir , filenameOne ) ;
const filenameOne = 'watch.txt' ;
const filepathOne = path . join ( testDir , filenameOne ) ;
var filenameTwo = 'hasOwnProperty' ;
var filepathTwo = filenameTwo ;
var filepathTwoAbs = path . join ( testDir , filenameTwo ) ;
const filenameTwo = 'hasOwnProperty' ;
const filepathTwo = filenameTwo ;
const filepathTwoAbs = path . join ( testDir , filenameTwo ) ;
process . on ( 'exit' , function ( ) {
assert . ok ( watchSeenOne > 0 ) ;
@ -33,12 +33,12 @@ fs.writeFileSync(filepathOne, 'hello');
assert . doesNotThrow (
function ( ) {
var watcher = fs . watch ( filepathOne ) ;
const watcher = fs . watch ( filepathOne ) ;
watcher . on ( 'change' , function ( event , filename ) {
assert . e qual( 'change' , event ) ;
assert . strictE qual( 'change' , event ) ;
if ( expectFilePath ) {
assert . e qual( 'watch.txt' , filename ) ;
assert . strictE qual( 'watch.txt' , filename ) ;
}
watcher . close ( ) ;
++ watchSeenOne ;
@ -57,11 +57,11 @@ fs.writeFileSync(filepathTwoAbs, 'howdy');
assert . doesNotThrow (
function ( ) {
var watcher = fs . watch ( filepathTwo , function ( event , filename ) {
assert . e qual( 'change' , event ) ;
const watcher = fs . watch ( filepathTwo , function ( event , filename ) {
assert . strictE qual( 'change' , event ) ;
if ( expectFilePath ) {
assert . e qual( 'hasOwnProperty' , filename ) ;
assert . strictE qual( 'hasOwnProperty' , filename ) ;
}
watcher . close ( ) ;
++ watchSeenTwo ;
@ -79,13 +79,13 @@ const filepathThree = path.join(testsubdir, filenameThree);
assert . doesNotThrow (
function ( ) {
var watcher = fs . watch ( testsubdir , function ( event , filename ) {
var renameEv = common . isSunOS ? 'change' : 'rename' ;
assert . e qual( renameEv , event ) ;
const watcher = fs . watch ( testsubdir , function ( event , filename ) {
const renameEv = common . isSunOS ? 'change' : 'rename' ;
assert . strictE qual( renameEv , event ) ;
if ( expectFilePath ) {
assert . e qual( 'newfile.txt' , filename ) ;
assert . strictE qual( 'newfile.txt' , filename ) ;
} else {
assert . e qual( null , filename ) ;
assert . strictE qual( null , filename ) ;
}
watcher . close ( ) ;
++ watchSeenThree ;
@ -94,7 +94,7 @@ assert.doesNotThrow(
) ;
setImmediate ( function ( ) {
var fd = fs . openSync ( filepathThree , 'w' ) ;
const fd = fs . openSync ( filepathThree , 'w' ) ;
fs . closeSync ( fd ) ;
} ) ;
@ -106,9 +106,9 @@ fs.watch(__filename, {persistent: false}, function() {
// whitebox test to ensure that wrapped FSEvent is safe
// https://github.com/joyent/node/issues/6690
var oldhandle ;
let oldhandle ;
assert . throws ( function ( ) {
var w = fs . watch ( __ filename , function ( event , filename ) { } ) ;
const w = fs . watch ( __ filename , function ( event , filename ) { } ) ;
oldhandle = w . _ handle ;
w . _ handle = { close : w . _ handle . close } ;
w . close ( ) ;
@ -116,7 +116,7 @@ assert.throws(function() {
oldhandle . close ( ) ; // clean up
assert . throws ( function ( ) {
var w = fs . watchFile ( __ filename , { persistent : false } , function ( ) { } ) ;
const w = fs . watchFile ( __ filename , { persistent : false } , function ( ) { } ) ;
oldhandle = w . _ handle ;
w . _ handle = { stop : w . _ handle . stop } ;
w . stop ( ) ;