@@ -63,10 +63,10 @@ if (!common.isWindows && process.getuid() === 0) {
63
63
}
64
64
}
65
65
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' ) ;
70
70
71
71
const throwNextTick = ( e ) => { process . nextTick ( ( ) => { throw e ; } ) ; } ;
72
72
@@ -76,16 +76,16 @@ fs.access(__filename, common.mustCall(function(...args) {
76
76
fs . promises . access ( __filename )
77
77
. then ( common . mustCall ( ) )
78
78
. 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 ) {
80
80
assert . deepStrictEqual ( args , [ null ] ) ;
81
81
} ) ) ;
82
- fs . promises . access ( __filename , fs . R_OK )
82
+ fs . promises . access ( __filename , fs . constants . R_OK )
83
83
. then ( common . mustCall ( ) )
84
84
. 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 ) {
86
86
assert . deepStrictEqual ( args , [ null ] ) ;
87
87
} ) ) ;
88
- fs . promises . access ( readOnlyFile , fs . R_OK )
88
+ fs . promises . access ( readOnlyFile , fs . constants . R_OK )
89
89
. then ( common . mustCall ( ) )
90
90
. catch ( throwNextTick ) ;
91
91
@@ -111,8 +111,8 @@ fs.promises.access(readOnlyFile, fs.R_OK)
111
111
assert . strictEqual ( err . path , readOnlyFile ) ;
112
112
}
113
113
}
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 )
116
116
. then ( common . mustNotCall ( ) , common . mustCall ( expectedError ) )
117
117
. catch ( throwNextTick ) ;
118
118
}
@@ -124,18 +124,18 @@ fs.promises.access(readOnlyFile, fs.R_OK)
124
124
return true ;
125
125
} ;
126
126
assert . throws (
127
- ( ) => { fs . access ( 100 , fs . F_OK , common . mustNotCall ( ) ) ; } ,
127
+ ( ) => { fs . access ( 100 , fs . constants . F_OK , common . mustNotCall ( ) ) ; } ,
128
128
expectedError
129
129
) ;
130
130
131
- fs . promises . access ( 100 , fs . F_OK )
131
+ fs . promises . access ( 100 , fs . constants . F_OK )
132
132
. then ( common . mustNotCall ( ) , common . mustCall ( expectedError ) )
133
133
. catch ( throwNextTick ) ;
134
134
}
135
135
136
136
assert . throws (
137
137
( ) => {
138
- fs . access ( __filename , fs . F_OK ) ;
138
+ fs . access ( __filename , fs . constants . F_OK ) ;
139
139
} ,
140
140
{
141
141
code : 'ERR_INVALID_ARG_TYPE' ,
@@ -144,7 +144,7 @@ assert.throws(
144
144
145
145
assert . throws (
146
146
( ) => {
147
- fs . access ( __filename , fs . F_OK , common . mustNotMutateObjectDeep ( { } ) ) ;
147
+ fs . access ( __filename , fs . constants . F_OK , common . mustNotMutateObjectDeep ( { } ) ) ;
148
148
} ,
149
149
{
150
150
code : 'ERR_INVALID_ARG_TYPE' ,
@@ -153,14 +153,14 @@ assert.throws(
153
153
154
154
// Regular access should not throw.
155
155
fs . accessSync ( __filename ) ;
156
- const mode = fs . R_OK | fs . W_OK ;
156
+ const mode = fs . constants . R_OK | fs . constants . W_OK ;
157
157
fs . accessSync ( readWriteFile , mode ) ;
158
158
159
159
// Invalid modes should throw.
160
160
[
161
161
false ,
162
162
1n ,
163
- { [ Symbol . toPrimitive ] ( ) { return fs . R_OK ; } } ,
163
+ { [ Symbol . toPrimitive ] ( ) { return fs . constants . R_OK ; } } ,
164
164
[ 1 ] ,
165
165
'r' ,
166
166
] . forEach ( ( mode , i ) => {
0 commit comments