Skip to content

Commit 25dd206

Browse files
fs: remove fs.F_OK, fs.R_OK, fs.W_OK, fs.X_OK
PR-URL: #55862 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent e2bc395 commit 25dd206

File tree

4 files changed

+11
-71
lines changed

4 files changed

+11
-71
lines changed

doc/api/deprecations.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -3589,6 +3589,9 @@ The [`util.toUSVString()`][] API is deprecated. Please use
35893589

35903590
<!-- YAML
35913591
changes:
3592+
- version: REPLACEME
3593+
pr-url: https://github.com/nodejs/node/pull/55862
3594+
description: End-of-Life.
35923595
- version: REPLACEME
35933596
pr-url: https://github.com/nodejs/node/pull/49686
35943597
description: Runtime deprecation.
@@ -3597,10 +3600,10 @@ changes:
35973600
description: Documentation-only deprecation.
35983601
-->
35993602

3600-
Type: Runtime
3603+
Type: End-of-Life
36013604

3602-
`F_OK`, `R_OK`, `W_OK` and `X_OK` getters exposed directly on `node:fs` are
3603-
deprecated. Get them from `fs.constants` or `fs.promises.constants` instead.
3605+
`F_OK`, `R_OK`, `W_OK` and `X_OK` getters exposed directly on `node:fs` were
3606+
removed. Get them from `fs.constants` or `fs.promises.constants` instead.
36043607

36053608
### DEP0177: `util.types.isWebAssemblyCompiledModule`
36063609

doc/api/fs.md

+4
Original file line numberDiff line numberDiff line change
@@ -1927,6 +1927,10 @@ concurrent modifications on the same file or data corruption may occur.
19271927
<!-- YAML
19281928
added: v0.11.15
19291929
changes:
1930+
- version: REPLACEME
1931+
pr-url: https://github.com/nodejs/node/pull/55862
1932+
description: The constants `fs.F_OK`, `fs.R_OK`, `fs.W_OK` and `fs.X_OK`
1933+
which were present directly on `fs` are removed.
19301934
- version: v20.8.0
19311935
pr-url: https://github.com/nodejs/node/pull/49683
19321936
description: The constants `fs.F_OK`, `fs.R_OK`, `fs.W_OK` and `fs.X_OK`

lib/fs.js

-48
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ const {
5252
S_IFREG,
5353
S_IFSOCK,
5454
F_OK,
55-
R_OK,
56-
W_OK,
57-
X_OK,
5855
O_WRONLY,
5956
O_SYMLINK,
6057
} = constants;
@@ -87,7 +84,6 @@ const {
8784
const { toPathIfFileURL } = require('internal/url');
8885
const {
8986
customPromisifyArgs: kCustomPromisifyArgsSymbol,
90-
deprecate,
9187
emitExperimentalWarning,
9288
getLazy,
9389
kEmptyObject,
@@ -3358,50 +3354,6 @@ defineLazyProperties(
33583354
);
33593355

33603356
ObjectDefineProperties(fs, {
3361-
F_OK: {
3362-
__proto__: null,
3363-
enumerable: false,
3364-
get: deprecate(
3365-
function get() {
3366-
return F_OK || 0;
3367-
},
3368-
'fs.F_OK is deprecated, use fs.constants.F_OK instead',
3369-
'DEP0176',
3370-
),
3371-
},
3372-
R_OK: {
3373-
__proto__: null,
3374-
enumerable: false,
3375-
get: deprecate(
3376-
function get() {
3377-
return R_OK || 0;
3378-
},
3379-
'fs.R_OK is deprecated, use fs.constants.R_OK instead',
3380-
'DEP0176',
3381-
),
3382-
},
3383-
W_OK: {
3384-
__proto__: null,
3385-
enumerable: false,
3386-
get: deprecate(
3387-
function get() {
3388-
return W_OK || 0;
3389-
},
3390-
'fs.W_OK is deprecated, use fs.constants.W_OK instead',
3391-
'DEP0176',
3392-
),
3393-
},
3394-
X_OK: {
3395-
__proto__: null,
3396-
enumerable: false,
3397-
get: deprecate(
3398-
function get() {
3399-
return X_OK || 0;
3400-
},
3401-
'fs.X_OK is deprecated, use fs.constants.X_OK instead',
3402-
'DEP0176',
3403-
),
3404-
},
34053357
constants: {
34063358
__proto__: null,
34073359
configurable: false,

test/parallel/test-fs-constants.js

+1-20
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
11
'use strict';
2-
const { expectWarning } = require('../common');
2+
require('../common');
33
const fs = require('fs');
44
const assert = require('assert');
55

66
// Check if the two constants accepted by chmod() on Windows are defined.
77
assert.notStrictEqual(fs.constants.S_IRUSR, undefined);
88
assert.notStrictEqual(fs.constants.S_IWUSR, undefined);
9-
10-
// Check for runtime deprecation warning, there should be no setter
11-
const { F_OK, R_OK, W_OK, X_OK } = fs.constants;
12-
13-
assert.throws(() => { fs.F_OK = 'overwritten'; }, { name: 'TypeError' });
14-
assert.throws(() => { fs.R_OK = 'overwritten'; }, { name: 'TypeError' });
15-
assert.throws(() => { fs.W_OK = 'overwritten'; }, { name: 'TypeError' });
16-
assert.throws(() => { fs.X_OK = 'overwritten'; }, { name: 'TypeError' });
17-
18-
expectWarning(
19-
'DeprecationWarning',
20-
'fs.F_OK is deprecated, use fs.constants.F_OK instead',
21-
'DEP0176'
22-
);
23-
24-
assert.strictEqual(fs.F_OK, F_OK);
25-
assert.strictEqual(fs.R_OK, R_OK);
26-
assert.strictEqual(fs.W_OK, W_OK);
27-
assert.strictEqual(fs.X_OK, X_OK);

0 commit comments

Comments
 (0)