@@ -3,19 +3,19 @@ const common = require('../common');
33const assert = require ( 'assert' ) ;
44const fs = require ( 'fs' ) ;
55const path = require ( 'path' ) ;
6- var doesNotExist = path . join ( common . tmpDir , '__this_should_not_exist' ) ;
7- var readOnlyFile = path . join ( common . tmpDir , 'read_only_file' ) ;
8- var readWriteFile = path . join ( common . tmpDir , 'read_write_file' ) ;
6+ const doesNotExist = path . join ( common . tmpDir , '__this_should_not_exist' ) ;
7+ const readOnlyFile = path . join ( common . tmpDir , 'read_only_file' ) ;
8+ const readWriteFile = path . join ( common . tmpDir , 'read_write_file' ) ;
99
10- var removeFile = function ( file ) {
10+ const removeFile = function ( file ) {
1111 try {
1212 fs . unlinkSync ( file ) ;
1313 } catch ( err ) {
1414 // Ignore error
1515 }
1616} ;
1717
18- var createFileWithPerms = function ( file , mode ) {
18+ const createFileWithPerms = function ( file , mode ) {
1919 removeFile ( file ) ;
2020 fs . writeFileSync ( file , '' ) ;
2121 fs . chmodSync ( file , mode ) ;
@@ -48,7 +48,7 @@ createFileWithPerms(readWriteFile, 0o666);
4848 * id, but that's fine. In this case, it is the responsability of the
4949 * continuous integration platform to take care of that.
5050 */
51- var hasWriteAccessForReadonlyFile = false ;
51+ let hasWriteAccessForReadonlyFile = false ;
5252if ( ! common . isWindows && process . getuid ( ) === 0 ) {
5353 hasWriteAccessForReadonlyFile = true ;
5454 try {
@@ -63,62 +63,62 @@ assert.strictEqual(typeof fs.R_OK, 'number');
6363assert . strictEqual ( typeof fs . W_OK , 'number' ) ;
6464assert . strictEqual ( typeof fs . X_OK , 'number' ) ;
6565
66- fs . access ( __filename , function ( err ) {
67- assert . strictEqual ( err , null , 'error should not exist' ) ;
68- } ) ;
66+ fs . access ( __filename , common . mustCall ( ( err ) => {
67+ assert . ifError ( err ) ;
68+ } ) ) ;
6969
70- fs . access ( __filename , fs . R_OK , function ( err ) {
71- assert . strictEqual ( err , null , 'error should not exist' ) ;
72- } ) ;
70+ fs . access ( __filename , fs . R_OK , common . mustCall ( ( err ) => {
71+ assert . ifError ( err ) ;
72+ } ) ) ;
7373
74- fs . access ( doesNotExist , function ( err ) {
74+ fs . access ( doesNotExist , common . mustCall ( ( err ) => {
7575 assert . notEqual ( err , null , 'error should exist' ) ;
7676 assert . strictEqual ( err . code , 'ENOENT' ) ;
7777 assert . strictEqual ( err . path , doesNotExist ) ;
78- } ) ;
78+ } ) ) ;
7979
80- fs . access ( readOnlyFile , fs . F_OK | fs . R_OK , function ( err ) {
81- assert . strictEqual ( err , null , 'error should not exist' ) ;
82- } ) ;
80+ fs . access ( readOnlyFile , fs . F_OK | fs . R_OK , common . mustCall ( ( err ) => {
81+ assert . ifError ( err ) ;
82+ } ) ) ;
8383
84- fs . access ( readOnlyFile , fs . W_OK , function ( err ) {
84+ fs . access ( readOnlyFile , fs . W_OK , common . mustCall ( ( err ) => {
8585 if ( hasWriteAccessForReadonlyFile ) {
86- assert . equal ( err , null , 'error should not exist' ) ;
86+ assert . ifError ( err ) ;
8787 } else {
8888 assert . notEqual ( err , null , 'error should exist' ) ;
8989 assert . strictEqual ( err . path , readOnlyFile ) ;
9090 }
91- } ) ;
91+ } ) ) ;
9292
93- assert . throws ( function ( ) {
94- fs . access ( 100 , fs . F_OK , function ( err ) { } ) ;
93+ assert . throws ( ( ) => {
94+ fs . access ( 100 , fs . F_OK , ( err ) => { } ) ;
9595} , / p a t h m u s t b e a s t r i n g o r B u f f e r / ) ;
9696
97- assert . throws ( function ( ) {
97+ assert . throws ( ( ) => {
9898 fs . access ( __filename , fs . F_OK ) ;
9999} , / " c a l l b a c k " a r g u m e n t m u s t b e a f u n c t i o n / ) ;
100100
101- assert . throws ( function ( ) {
101+ assert . throws ( ( ) => {
102102 fs . access ( __filename , fs . F_OK , { } ) ;
103103} , / " c a l l b a c k " a r g u m e n t m u s t b e a f u n c t i o n / ) ;
104104
105- assert . doesNotThrow ( function ( ) {
105+ assert . doesNotThrow ( ( ) => {
106106 fs . accessSync ( __filename ) ;
107107} ) ;
108108
109- assert . doesNotThrow ( function ( ) {
109+ assert . doesNotThrow ( ( ) => {
110110 var mode = fs . F_OK | fs . R_OK | fs . W_OK ;
111111
112112 fs . accessSync ( readWriteFile , mode ) ;
113113} ) ;
114114
115- assert . throws ( function ( ) {
115+ assert . throws ( ( ) => {
116116 fs . accessSync ( doesNotExist ) ;
117- } , function ( err ) {
117+ } , ( err ) => {
118118 return err . code === 'ENOENT' && err . path === doesNotExist ;
119119} ) ;
120120
121- process . on ( 'exit' , function ( ) {
121+ process . on ( 'exit' , ( ) => {
122122 removeFile ( readOnlyFile ) ;
123123 removeFile ( readWriteFile ) ;
124124} ) ;
0 commit comments