Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -3577,12 +3577,15 @@ The [`util.toUSVString()`][] API is deprecated. Please use

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/49686
description: Runtime deprecation.
- version: v20.8.0
pr-url: https://github.com/nodejs/node/pull/49683
description: Documentation-only deprecation.
-->

Type: Documentation-only
Type: Runtime

`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.
Expand Down
49 changes: 45 additions & 4 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const {
const { toPathIfFileURL } = require('internal/url');
const {
customPromisifyArgs: kCustomPromisifyArgsSymbol,
deprecate,
emitExperimentalWarning,
getLazy,
kEmptyObject,
Expand Down Expand Up @@ -3274,10 +3275,50 @@ defineLazyProperties(
);

ObjectDefineProperties(fs, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F_OK: { __proto__: null, enumerable: true, value: F_OK || 0 },
R_OK: { __proto__: null, enumerable: true, value: R_OK || 0 },
W_OK: { __proto__: null, enumerable: true, value: W_OK || 0 },
X_OK: { __proto__: null, enumerable: true, value: X_OK || 0 },
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
Loading