@@ -63,10 +63,10 @@ if (!common.isWindows && process.getuid() === 0) {
6363 }
6464}
6565
66- assert . strictEqual ( typeof fs . F_OK , 'number' ) ;
67- assert . strictEqual ( typeof fs . R_OK , 'number' ) ;
68- assert . strictEqual ( typeof fs . W_OK , 'number' ) ;
69- assert . strictEqual ( typeof fs . X_OK , 'number' ) ;
66+ assert . strictEqual ( typeof fs . constants . F_OK , 'number' ) ;
67+ assert . strictEqual ( typeof fs . constants . R_OK , 'number' ) ;
68+ assert . strictEqual ( typeof fs . constants . W_OK , 'number' ) ;
69+ assert . strictEqual ( typeof fs . constants . X_OK , 'number' ) ;
7070
7171const throwNextTick = ( e ) => { process . nextTick ( ( ) => { throw e ; } ) ; } ;
7272
@@ -76,16 +76,16 @@ fs.access(__filename, common.mustCall(function(...args) {
7676fs . promises . access ( __filename )
7777 . then ( common . mustCall ( ) )
7878 . catch ( throwNextTick ) ;
79- fs . access ( __filename , fs . R_OK , common . mustCall ( function ( ...args ) {
79+ fs . access ( __filename , fs . constants . R_OK , common . mustCall ( function ( ...args ) {
8080 assert . deepStrictEqual ( args , [ null ] ) ;
8181} ) ) ;
82- fs . promises . access ( __filename , fs . R_OK )
82+ fs . promises . access ( __filename , fs . constants . R_OK )
8383 . then ( common . mustCall ( ) )
8484 . catch ( throwNextTick ) ;
85- fs . access ( readOnlyFile , fs . R_OK , common . mustCall ( function ( ...args ) {
85+ fs . access ( readOnlyFile , fs . constants . R_OK , common . mustCall ( function ( ...args ) {
8686 assert . deepStrictEqual ( args , [ null ] ) ;
8787} ) ) ;
88- fs . promises . access ( readOnlyFile , fs . R_OK )
88+ fs . promises . access ( readOnlyFile , fs . constants . R_OK )
8989 . then ( common . mustCall ( ) )
9090 . catch ( throwNextTick ) ;
9191
@@ -111,8 +111,8 @@ fs.promises.access(readOnlyFile, fs.R_OK)
111111 assert . strictEqual ( err . path , readOnlyFile ) ;
112112 }
113113 }
114- fs . access ( readOnlyFile , fs . W_OK , common . mustCall ( expectedError ) ) ;
115- fs . promises . access ( readOnlyFile , fs . W_OK )
114+ fs . access ( readOnlyFile , fs . constants . W_OK , common . mustCall ( expectedError ) ) ;
115+ fs . promises . access ( readOnlyFile , fs . constants . W_OK )
116116 . then ( common . mustNotCall ( ) , common . mustCall ( expectedError ) )
117117 . catch ( throwNextTick ) ;
118118}
@@ -124,18 +124,18 @@ fs.promises.access(readOnlyFile, fs.R_OK)
124124 return true ;
125125 } ;
126126 assert . throws (
127- ( ) => { fs . access ( 100 , fs . F_OK , common . mustNotCall ( ) ) ; } ,
127+ ( ) => { fs . access ( 100 , fs . constants . F_OK , common . mustNotCall ( ) ) ; } ,
128128 expectedError
129129 ) ;
130130
131- fs . promises . access ( 100 , fs . F_OK )
131+ fs . promises . access ( 100 , fs . constants . F_OK )
132132 . then ( common . mustNotCall ( ) , common . mustCall ( expectedError ) )
133133 . catch ( throwNextTick ) ;
134134}
135135
136136assert . throws (
137137 ( ) => {
138- fs . access ( __filename , fs . F_OK ) ;
138+ fs . access ( __filename , fs . constants . F_OK ) ;
139139 } ,
140140 {
141141 code : 'ERR_INVALID_ARG_TYPE' ,
@@ -144,7 +144,7 @@ assert.throws(
144144
145145assert . throws (
146146 ( ) => {
147- fs . access ( __filename , fs . F_OK , common . mustNotMutateObjectDeep ( { } ) ) ;
147+ fs . access ( __filename , fs . constants . F_OK , common . mustNotMutateObjectDeep ( { } ) ) ;
148148 } ,
149149 {
150150 code : 'ERR_INVALID_ARG_TYPE' ,
@@ -153,14 +153,14 @@ assert.throws(
153153
154154// Regular access should not throw.
155155fs . accessSync ( __filename ) ;
156- const mode = fs . R_OK | fs . W_OK ;
156+ const mode = fs . constants . R_OK | fs . constants . W_OK ;
157157fs . accessSync ( readWriteFile , mode ) ;
158158
159159// Invalid modes should throw.
160160[
161161 false ,
162162 1n ,
163- { [ Symbol . toPrimitive ] ( ) { return fs . R_OK ; } } ,
163+ { [ Symbol . toPrimitive ] ( ) { return fs . constants . R_OK ; } } ,
164164 [ 1 ] ,
165165 'r' ,
166166] . forEach ( ( mode , i ) => {
0 commit comments