mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
BREAKING(fs): remove Deno.FsFile.prototype.rid
(#25499)
Towards #22079 --------- Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
parent
f9007d3386
commit
a69b1e699e
17 changed files with 38 additions and 44 deletions
15
cli/tsc/dts/lib.deno.ns.d.ts
vendored
15
cli/tsc/dts/lib.deno.ns.d.ts
vendored
|
@ -1815,15 +1815,6 @@ declare namespace Deno {
|
|||
* @category File System
|
||||
*/
|
||||
export class FsFile implements Seeker, SeekerSync, Disposable {
|
||||
/**
|
||||
* The resource ID associated with the file instance. The resource ID
|
||||
* should be considered an opaque reference to resource.
|
||||
*
|
||||
* @deprecated This will be removed in Deno 2.0. See the
|
||||
* {@link https://docs.deno.com/runtime/manual/advanced/migrate_deprecations | Deno 1.x to 2.x Migration Guide}
|
||||
* for migration instructions.
|
||||
*/
|
||||
readonly rid: number;
|
||||
/** A {@linkcode ReadableStream} instance representing to the byte contents
|
||||
* of the file. This makes it easy to interoperate with other web streams
|
||||
* based APIs.
|
||||
|
@ -1973,7 +1964,7 @@ declare namespace Deno {
|
|||
* resolves to the new position within the resource (bytes from the start).
|
||||
*
|
||||
* ```ts
|
||||
* // Given file pointing to file with "Hello world", which is 11 bytes long:
|
||||
* // Given the file contains "Hello world" text, which is 11 bytes long:
|
||||
* using file = await Deno.open(
|
||||
* "hello.txt",
|
||||
* { read: true, write: true, truncate: true, create: true },
|
||||
|
@ -1991,7 +1982,7 @@ declare namespace Deno {
|
|||
* The seek modes work as follows:
|
||||
*
|
||||
* ```ts
|
||||
* // Given file.rid pointing to file with "Hello world", which is 11 bytes long:
|
||||
* // Given the file contains "Hello world" text, which is 11 bytes long:
|
||||
* const file = await Deno.open(
|
||||
* "hello.txt",
|
||||
* { read: true, write: true, truncate: true, create: true },
|
||||
|
@ -2028,7 +2019,7 @@ declare namespace Deno {
|
|||
* The seek modes work as follows:
|
||||
*
|
||||
* ```ts
|
||||
* // Given file.rid pointing to file with "Hello world", which is 11 bytes long:
|
||||
* // Given the file contains "Hello world" text, which is 11 bytes long:
|
||||
* using file = Deno.openSync(
|
||||
* "hello.txt",
|
||||
* { read: true, write: true, truncate: true, create: true },
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { core, internals, primordials } from "ext:core/mod.js";
|
||||
import { core, primordials } from "ext:core/mod.js";
|
||||
const {
|
||||
isDate,
|
||||
internalRidSymbol,
|
||||
|
@ -581,15 +581,6 @@ class FsFile {
|
|||
}
|
||||
}
|
||||
|
||||
get rid() {
|
||||
internals.warnOnDeprecatedApi(
|
||||
"Deno.FsFile.rid",
|
||||
new Error().stack,
|
||||
"Use `Deno.FsFile` methods directly instead.",
|
||||
);
|
||||
return this.#rid;
|
||||
}
|
||||
|
||||
write(p) {
|
||||
return write(this.#rid, p);
|
||||
}
|
||||
|
|
|
@ -783,7 +783,6 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
|
|||
}
|
||||
if (internals.future) {
|
||||
delete globalThis.window;
|
||||
delete Deno.FsFile.prototype.rid;
|
||||
}
|
||||
} else {
|
||||
// Warmup
|
||||
|
@ -930,10 +929,6 @@ function bootstrapWorkerRuntime(
|
|||
nodeDebug,
|
||||
});
|
||||
}
|
||||
|
||||
if (internals.future) {
|
||||
delete Deno.FsFile.prototype.rid;
|
||||
}
|
||||
} else {
|
||||
// Warmup
|
||||
return;
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
console.log("window is", globalThis.window);
|
||||
console.log(
|
||||
"Deno.FsFile.prototype.rid is",
|
||||
Deno.openSync(import.meta.filename).rid,
|
||||
);
|
||||
|
||||
// TCP
|
||||
// Since these tests may run in parallel, ensure this port is unique to this file
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
window is undefined
|
||||
Deno.FsFile.prototype.rid is undefined
|
||||
Deno.Listener.prototype.rid is undefined
|
||||
Deno.TlsListener.prototype.rid is undefined
|
||||
Deno.FsFile constructor is illegal
|
||||
|
|
|
@ -26,7 +26,6 @@ Deno.test(
|
|||
const filename = "tests/testdata/assets/fixture.json";
|
||||
using file = await Deno.open(filename);
|
||||
assert(file instanceof Deno.FsFile);
|
||||
assert(file.rid > 2);
|
||||
const bytesWritten = await copy(file, Deno.stdout);
|
||||
const fileSize = Deno.statSync(filename).size;
|
||||
assertEquals(bytesWritten, fileSize);
|
||||
|
|
|
@ -6,7 +6,6 @@ import {
|
|||
assertStrictEquals,
|
||||
assertStringIncludes,
|
||||
assertThrows,
|
||||
DENO_FUTURE,
|
||||
} from "./test_util.ts";
|
||||
|
||||
Deno.test(
|
||||
|
@ -363,8 +362,6 @@ Deno.test(
|
|||
|
||||
Deno.test(
|
||||
{
|
||||
// Ignoring because uses `file.rid`
|
||||
ignore: DENO_FUTURE,
|
||||
permissions: { run: true, write: true, read: true },
|
||||
},
|
||||
async function runRedirectStdoutStderr() {
|
||||
|
@ -382,10 +379,12 @@ Deno.test(
|
|||
"eval",
|
||||
"Deno.stderr.write(new TextEncoder().encode('error\\n')); Deno.stdout.write(new TextEncoder().encode('output\\n'));",
|
||||
],
|
||||
stdout: file.rid,
|
||||
stderr: file.rid,
|
||||
stdout: "piped",
|
||||
stderr: "piped",
|
||||
});
|
||||
|
||||
await p.stdout.readable.pipeTo(file.writable, { preventClose: true });
|
||||
await p.stderr.readable.pipeTo(file.writable);
|
||||
await p.status();
|
||||
p.close();
|
||||
|
||||
|
@ -402,8 +401,6 @@ Deno.test(
|
|||
|
||||
Deno.test(
|
||||
{
|
||||
// Ignoring because uses `file.rid`
|
||||
ignore: DENO_FUTURE,
|
||||
permissions: { run: true, write: true, read: true },
|
||||
},
|
||||
async function runRedirectStdin() {
|
||||
|
@ -425,9 +422,10 @@ Deno.test(
|
|||
}
|
||||
`,
|
||||
],
|
||||
stdin: file.rid,
|
||||
stdin: "piped",
|
||||
});
|
||||
|
||||
await file.readable.pipeTo(p.stdin.writable);
|
||||
const status = await p.status();
|
||||
assertEquals(status.code, 0);
|
||||
p.close();
|
||||
|
|
|
@ -75,6 +75,7 @@ Deno.test({
|
|||
read: true,
|
||||
});
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
appendFile(file.rid, "hello world", (err) => {
|
||||
if (err) reject();
|
||||
else resolve();
|
||||
|
@ -166,6 +167,7 @@ Deno.test({
|
|||
write: true,
|
||||
read: true,
|
||||
});
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
appendFileSync(file.rid, "hello world");
|
||||
const data = Deno.readFileSync(tempFile);
|
||||
assertEquals(decoder.decode(data), "hello world");
|
||||
|
|
|
@ -13,6 +13,7 @@ Deno.test({
|
|||
const file: Deno.FsFile = await Deno.open(tempFile);
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
close(file.rid, (err) => {
|
||||
if (err !== null) reject();
|
||||
else resolve();
|
||||
|
@ -45,6 +46,7 @@ Deno.test({
|
|||
|
||||
let foo: string;
|
||||
const promise = new Promise<void>((resolve) => {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
close(file.rid, () => {
|
||||
assert(foo === "bar");
|
||||
resolve();
|
||||
|
@ -66,6 +68,7 @@ Deno.test({
|
|||
const tempFile: string = Deno.makeTempFileSync();
|
||||
const file: Deno.FsFile = Deno.openSync(tempFile);
|
||||
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
closeSync(file.rid);
|
||||
Deno.removeSync(tempFile);
|
||||
},
|
||||
|
|
|
@ -19,6 +19,7 @@ Deno.test({
|
|||
await file.write(data);
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
fdatasync(file.rid, (err: Error | null) => {
|
||||
if (err !== null) reject();
|
||||
else resolve();
|
||||
|
@ -55,6 +56,7 @@ Deno.test({
|
|||
file.writeSync(data);
|
||||
|
||||
try {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
fdatasyncSync(file.rid);
|
||||
assertEquals(Deno.readFileSync(filePath), data);
|
||||
} finally {
|
||||
|
|
|
@ -15,6 +15,7 @@ Deno.test({
|
|||
using file = await Deno.open(filePath);
|
||||
|
||||
await new Promise<Stats>((resolve, reject) => {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
fstat(file.rid, (err: Error | null, stat: Stats) => {
|
||||
if (err) reject(err);
|
||||
resolve(stat);
|
||||
|
@ -43,6 +44,7 @@ Deno.test({
|
|||
|
||||
await new Promise<BigIntStats>((resolve, reject) => {
|
||||
fstat(
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
file.rid,
|
||||
{ bigint: true },
|
||||
(err: Error | null, stat: BigIntStats) => {
|
||||
|
@ -71,6 +73,7 @@ Deno.test({
|
|||
using file = Deno.openSync(filePath);
|
||||
|
||||
try {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
assertStats(fstatSync(file.rid), file.statSync());
|
||||
} finally {
|
||||
Deno.removeSync(filePath);
|
||||
|
@ -89,9 +92,11 @@ Deno.test({
|
|||
|
||||
try {
|
||||
// HEAD
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
assertStatsBigInt(fstatSync(file.rid, { bigint: true }), file.statSync());
|
||||
//
|
||||
assertStatsBigInt(
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
fstatSync(file.rid, { bigint: true }),
|
||||
file.statSync(),
|
||||
);
|
||||
|
|
|
@ -18,6 +18,7 @@ Deno.test({
|
|||
await file.truncate(size);
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
fsync(file.rid, (err: Error | null) => {
|
||||
if (err !== null) reject();
|
||||
else resolve();
|
||||
|
@ -53,6 +54,7 @@ Deno.test({
|
|||
file.truncateSync(size);
|
||||
|
||||
try {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
fsyncSync(file.rid);
|
||||
assertEquals(Deno.statSync(filePath).size, size);
|
||||
} finally {
|
||||
|
|
|
@ -31,6 +31,7 @@ Deno.test({
|
|||
});
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
ftruncate(file.rid, (err: Error | null) => {
|
||||
if (err !== null) reject();
|
||||
else resolve();
|
||||
|
@ -66,6 +67,7 @@ Deno.test({
|
|||
});
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
ftruncate(file.rid, 3, (err: Error | null) => {
|
||||
if (err !== null) reject();
|
||||
else resolve();
|
||||
|
@ -101,6 +103,7 @@ Deno.test({
|
|||
});
|
||||
|
||||
try {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
ftruncateSync(file.rid);
|
||||
const fileInfo: Deno.FileInfo = Deno.lstatSync(filePath);
|
||||
assertEquals(fileInfo.size, 0);
|
||||
|
@ -125,6 +128,7 @@ Deno.test({
|
|||
});
|
||||
|
||||
try {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
ftruncateSync(file.rid, 3);
|
||||
const fileInfo: Deno.FileInfo = Deno.lstatSync(filePath);
|
||||
assertEquals(fileInfo.size, 3);
|
||||
|
|
|
@ -15,6 +15,7 @@ Deno.test({
|
|||
using file = await Deno.open(filePath, { create: true, write: true });
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
futimes(file.rid, randomDate, randomDate, (err: Error | null) => {
|
||||
if (err !== null) reject();
|
||||
else resolve();
|
||||
|
@ -73,6 +74,7 @@ Deno.test({
|
|||
using file = Deno.openSync(filePath, { create: true, write: true });
|
||||
|
||||
try {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
futimesSync(file.rid, randomDate, randomDate);
|
||||
|
||||
const fileInfo: Deno.FileInfo = Deno.lstatSync(filePath);
|
||||
|
|
|
@ -119,6 +119,7 @@ Deno.test(
|
|||
});
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
writeFile(file.rid, "hello world", (err) => {
|
||||
if (err) return reject(err);
|
||||
resolve();
|
||||
|
@ -234,6 +235,7 @@ Deno.test(
|
|||
});
|
||||
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
writeFile(file.rid, "hello world", { mode: 0o777 }, (err) => {
|
||||
if (err) return reject(err);
|
||||
resolve();
|
||||
|
@ -288,6 +290,7 @@ Deno.test(
|
|||
read: true,
|
||||
});
|
||||
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
writeFileSync(file.rid, "hello world");
|
||||
|
||||
const data = Deno.readFileSync(tempFile);
|
||||
|
|
|
@ -22,6 +22,7 @@ Deno.test({
|
|||
});
|
||||
const buffer = Buffer.from("hello world");
|
||||
const bytesWrite = await new Promise((resolve, reject) => {
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
write(file.rid, buffer, 0, 5, (err: unknown, nwritten: number) => {
|
||||
if (err) return reject(err);
|
||||
resolve(nwritten);
|
||||
|
@ -49,6 +50,7 @@ Deno.test({
|
|||
read: true,
|
||||
});
|
||||
const buffer = Buffer.from("hello world");
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
const bytesWrite = writeSync(file.rid, buffer, 0, 5);
|
||||
|
||||
const data = Deno.readFileSync(tempFile);
|
||||
|
@ -75,6 +77,7 @@ Deno.test({
|
|||
|
||||
const str = "hello world";
|
||||
const buffer = Buffer.from(str);
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
const bytesWritten = writeSync(file.rid, buffer, 0, str.length, 4);
|
||||
|
||||
const data = Deno.readFileSync(tempFile);
|
||||
|
@ -122,6 +125,7 @@ Deno.test({
|
|||
for (let i = 0; i < bytes.length; i++) {
|
||||
buffer[offset + i] = i;
|
||||
}
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
let nWritten = writeSync(file.rid, buffer, offset, bytes.length, 0);
|
||||
|
||||
let data = Deno.readFileSync(tempFile);
|
||||
|
@ -131,6 +135,7 @@ Deno.test({
|
|||
assertEquals(data, new Uint8Array(bytes));
|
||||
nWritten = await new Promise((resolve, reject) =>
|
||||
write(
|
||||
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||
file.rid,
|
||||
buffer,
|
||||
offset,
|
||||
|
|
|
@ -10,9 +10,6 @@ Deno.test("[node/tty isatty] returns true when fd is a tty, false otherwise", ()
|
|||
assert(Deno.stdin.isTerminal() === isatty((Deno as any).stdin.rid));
|
||||
assert(Deno.stdout.isTerminal() === isatty((Deno as any).stdout.rid));
|
||||
assert(Deno.stderr.isTerminal() === isatty((Deno as any).stderr.rid));
|
||||
|
||||
using file = Deno.openSync("README.md");
|
||||
assert(!isatty(file.rid));
|
||||
});
|
||||
|
||||
Deno.test("[node/tty isatty] returns false for irrelevant values", () => {
|
||||
|
|
Loading…
Reference in a new issue