Skip to content

Commit

Permalink
fs: remove fs.F_OK, fs.R_OK, fs.W_OK, fs.X_OK
Browse files Browse the repository at this point in the history
  • Loading branch information
LiviaMedeiros committed Nov 15, 2024
1 parent b02cd41 commit 7aa2d97
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 71 deletions.
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/00000

Check warning on line 3581 in doc/api/deprecations.md

View workflow job for this annotation

GitHub Actions / lint-pr-url

pr-url doesn't match the URL of the current PR.
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/00000

Check warning on line 1924 in doc/api/fs.md

View workflow job for this annotation

GitHub Actions / lint-pr-url

pr-url doesn't match the URL of the current PR.
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);

0 comments on commit 7aa2d97

Please sign in to comment.