summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/unit_node/_fs/_fs_fstat_test.ts10
-rw-r--r--cli/tsc/dts/lib.deno.ns.d.ts6
-rw-r--r--ext/node/polyfills/_fs/_fs_fstat.ts5
-rw-r--r--runtime/js/90_deno_ns.js18
4 files changed, 32 insertions, 7 deletions
diff --git a/cli/tests/unit_node/_fs/_fs_fstat_test.ts b/cli/tests/unit_node/_fs/_fs_fstat_test.ts
index 963f79abc..220b9589a 100644
--- a/cli/tests/unit_node/_fs/_fs_fstat_test.ts
+++ b/cli/tests/unit_node/_fs/_fs_fstat_test.ts
@@ -18,7 +18,7 @@ Deno.test({
})
.then(
(stat) => {
- assertStats(stat, Deno.fstatSync(file.rid));
+ assertStats(stat, file.statSync());
},
() => fail(),
)
@@ -45,7 +45,7 @@ Deno.test({
);
})
.then(
- (stat) => assertStatsBigInt(stat, Deno.fstatSync(file.rid)),
+ (stat) => assertStatsBigInt(stat, file.statSync()),
() => fail(),
)
.finally(() => {
@@ -61,7 +61,7 @@ Deno.test({
using file = Deno.openSync(filePath);
try {
- assertStats(fstatSync(file.rid), Deno.fstatSync(file.rid));
+ assertStats(fstatSync(file.rid), file.statSync());
} finally {
Deno.removeSync(filePath);
}
@@ -75,10 +75,14 @@ Deno.test({
using file = Deno.openSync(filePath);
try {
+ // HEAD
+ assertStatsBigInt(fstatSync(file.rid, { bigint: true }), file.statSync());
+ //
assertStatsBigInt(
fstatSync(file.rid, { bigint: true }),
Deno.fstatSync(file.rid),
);
+ //main
} finally {
Deno.removeSync(filePath);
}
diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts
index 175276b66..9ec90a2d6 100644
--- a/cli/tsc/dts/lib.deno.ns.d.ts
+++ b/cli/tsc/dts/lib.deno.ns.d.ts
@@ -5448,6 +5448,9 @@ declare namespace Deno {
* assert(fileInfo.isFile);
* ```
*
+ * @deprecated Use `file.stat()` instead.
+ * {@linkcode Deno.fstat} will be removed in Deno 2.0.
+ *
* @category File System
*/
export function fstat(rid: number): Promise<FileInfo>;
@@ -5464,6 +5467,9 @@ declare namespace Deno {
* assert(fileInfo.isFile);
* ```
*
+ * @deprecated Use `file.statSync()` instead.
+ * {@linkcode Deno.fstatSync} will be removed in Deno 2.0.
+ *
* @category File System
*/
export function fstatSync(rid: number): FileInfo;
diff --git a/ext/node/polyfills/_fs/_fs_fstat.ts b/ext/node/polyfills/_fs/_fs_fstat.ts
index bc4cf3c42..fe97235bf 100644
--- a/ext/node/polyfills/_fs/_fs_fstat.ts
+++ b/ext/node/polyfills/_fs/_fs_fstat.ts
@@ -11,6 +11,7 @@ import {
statOptions,
Stats,
} from "ext:deno_node/_fs/_fs_stat.ts";
+import { FsFile } from "ext:deno_fs/30_fs.js";
export function fstat(fd: number, callback: statCallback): void;
export function fstat(
@@ -40,7 +41,7 @@ export function fstat(
if (!callback) throw new Error("No callback function supplied");
- Deno.fstat(fd).then(
+ new FsFile(fd).stat().then(
(stat) => callback(null, CFISBIS(stat, options.bigint)),
(err) => callback(err),
);
@@ -59,6 +60,6 @@ export function fstatSync(
fd: number,
options?: statOptions,
): Stats | BigIntStats {
- const origin = Deno.fstatSync(fd);
+ const origin = new FsFile(fd).statSync();
return CFISBIS(origin, options?.bigint || false);
}
diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js
index 638e7afe7..4340abc95 100644
--- a/runtime/js/90_deno_ns.js
+++ b/runtime/js/90_deno_ns.js
@@ -209,8 +209,22 @@ const denoNs = {
);
net.shutdown(rid);
},
- fstatSync: fs.fstatSync,
- fstat: fs.fstat,
+ fstatSync(rid) {
+ internals.warnOnDeprecatedApi(
+ "Deno.fstatSync()",
+ new Error().stack,
+ "Use `Deno.FsFile.statSync()` instead.",
+ );
+ return fs.fstatSync(rid);
+ },
+ fstat(rid) {
+ internals.warnOnDeprecatedApi(
+ "Deno.fstat()",
+ new Error().stack,
+ "Use `Deno.FsFile.stat()` instead.",
+ );
+ return fs.fstat(rid);
+ },
fsyncSync(rid) {
internals.warnOnDeprecatedApi(
"Deno.fsyncSync()",