mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
fs: runtime deprecate fs.Stats constructor
PR-URL: https://github.com/nodejs/node/pull/52067 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
This commit is contained in:
@@ -3581,12 +3581,15 @@ Please use the [`crypto.createHash()`][] method to create Hash instances.
|
||||
|
||||
<!-- YAML
|
||||
changes:
|
||||
- version: REPLACEME
|
||||
pr-url: https://github.com/nodejs/node/pull/52067
|
||||
description: Runtime deprecation.
|
||||
- version: REPLACEME
|
||||
pr-url: https://github.com/nodejs/node/pull/51879
|
||||
description: Documentation-only deprecation.
|
||||
-->
|
||||
|
||||
Type: Documentation-only
|
||||
Type: Runtime
|
||||
|
||||
Calling `fs.Stats` class directly with `Stats()` or `new Stats()` is
|
||||
deprecated due to being internals, not intended for public use.
|
||||
|
||||
@@ -51,6 +51,7 @@ const {
|
||||
const {
|
||||
kEmptyObject,
|
||||
once,
|
||||
deprecate,
|
||||
} = require('internal/util');
|
||||
const { toPathIfFileURL } = require('internal/url');
|
||||
const {
|
||||
@@ -1008,7 +1009,7 @@ module.exports = {
|
||||
getStatsFromBinding,
|
||||
stringToFlags,
|
||||
stringToSymlinkType,
|
||||
Stats,
|
||||
Stats: deprecate(Stats, 'fs.Stats constructor is deprecated.', 'DEP0180'),
|
||||
toUnixTimestamp,
|
||||
validateBufferArray,
|
||||
validateCpOptions,
|
||||
|
||||
@@ -154,3 +154,28 @@ fs.open(__filename, 'r', undefined, common.mustCall((err, fd) => {
|
||||
|
||||
// Should not throw an error
|
||||
fs.lstat(__filename, undefined, common.mustCall());
|
||||
|
||||
{
|
||||
fs.Stats(
|
||||
0, // dev
|
||||
0, // mode
|
||||
0, // nlink
|
||||
0, // uid
|
||||
0, // gid
|
||||
0, // rdev
|
||||
0, // blksize
|
||||
0, // ino
|
||||
0, // size
|
||||
0, // blocks
|
||||
Date.UTC(1970, 0, 1, 0, 0, 0), // atime
|
||||
Date.UTC(1970, 0, 1, 0, 0, 0), // mtime
|
||||
Date.UTC(1970, 0, 1, 0, 0, 0), // ctime
|
||||
Date.UTC(1970, 0, 1, 0, 0, 0) // birthtime
|
||||
);
|
||||
common.expectWarning({
|
||||
DeprecationWarning: [
|
||||
['fs.Stats constructor is deprecated.',
|
||||
'DEP0180'],
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user