Skip to content

fs: remove fs.F_OK, fs.R_OK, fs.W_OK, fs.X_OK #55862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -3577,6 +3577,9 @@ The [`util.toUSVString()`][] API is deprecated. Please use

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/55862
description: End-of-Life.
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/49686
description: Runtime deprecation.
Expand All @@ -3585,10 +3588,10 @@ changes:
description: Documentation-only deprecation.
-->

Type: Runtime
Type: End-of-Life

`F_OK`, `R_OK`, `W_OK` and `X_OK` getters exposed directly on `node:fs` are
deprecated. Get them from `fs.constants` or `fs.promises.constants` instead.
`F_OK`, `R_OK`, `W_OK` and `X_OK` getters exposed directly on `node:fs` were
removed. Get them from `fs.constants` or `fs.promises.constants` instead.

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

Expand Down
4 changes: 4 additions & 0 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,10 @@ concurrent modifications on the same file or data corruption may occur.
<!-- YAML
added: v0.11.15
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/55862
description: The constants `fs.F_OK`, `fs.R_OK`, `fs.W_OK` and `fs.X_OK`
which were present directly on `fs` are removed.
- version: v20.8.0
pr-url: https://github.com/nodejs/node/pull/49683
description: The constants `fs.F_OK`, `fs.R_OK`, `fs.W_OK` and `fs.X_OK`
Expand Down
48 changes: 0 additions & 48 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ const {
S_IFREG,
S_IFSOCK,
F_OK,
R_OK,
W_OK,
X_OK,
O_WRONLY,
O_SYMLINK,
} = constants;
Expand Down Expand Up @@ -87,7 +84,6 @@ const {
const { toPathIfFileURL } = require('internal/url');
const {
customPromisifyArgs: kCustomPromisifyArgsSymbol,
deprecate,
emitExperimentalWarning,
getLazy,
kEmptyObject,
Expand Down Expand Up @@ -3275,50 +3271,6 @@ defineLazyProperties(
);

ObjectDefineProperties(fs, {
F_OK: {
__proto__: null,
enumerable: false,
get: deprecate(
function get() {
return F_OK || 0;
},
'fs.F_OK is deprecated, use fs.constants.F_OK instead',
'DEP0176',
),
},
R_OK: {
__proto__: null,
enumerable: false,
get: deprecate(
function get() {
return R_OK || 0;
},
'fs.R_OK is deprecated, use fs.constants.R_OK instead',
'DEP0176',
),
},
W_OK: {
__proto__: null,
enumerable: false,
get: deprecate(
function get() {
return W_OK || 0;
},
'fs.W_OK is deprecated, use fs.constants.W_OK instead',
'DEP0176',
),
},
X_OK: {
__proto__: null,
enumerable: false,
get: deprecate(
function get() {
return X_OK || 0;
},
'fs.X_OK is deprecated, use fs.constants.X_OK instead',
'DEP0176',
),
},
constants: {
__proto__: null,
configurable: false,
Expand Down
21 changes: 1 addition & 20 deletions test/parallel/test-fs-constants.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
'use strict';
const { expectWarning } = require('../common');
require('../common');
const fs = require('fs');
const assert = require('assert');

// Check if the two constants accepted by chmod() on Windows are defined.
assert.notStrictEqual(fs.constants.S_IRUSR, undefined);
assert.notStrictEqual(fs.constants.S_IWUSR, undefined);

// Check for runtime deprecation warning, there should be no setter
const { F_OK, R_OK, W_OK, X_OK } = fs.constants;

assert.throws(() => { fs.F_OK = 'overwritten'; }, { name: 'TypeError' });
assert.throws(() => { fs.R_OK = 'overwritten'; }, { name: 'TypeError' });
assert.throws(() => { fs.W_OK = 'overwritten'; }, { name: 'TypeError' });
assert.throws(() => { fs.X_OK = 'overwritten'; }, { name: 'TypeError' });

expectWarning(
'DeprecationWarning',
'fs.F_OK is deprecated, use fs.constants.F_OK instead',
'DEP0176'
);

assert.strictEqual(fs.F_OK, F_OK);
assert.strictEqual(fs.R_OK, R_OK);
assert.strictEqual(fs.W_OK, W_OK);
assert.strictEqual(fs.X_OK, X_OK);
Loading