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
|
* @category File System
|
||||||
*/
|
*/
|
||||||
export class FsFile implements Seeker, SeekerSync, Disposable {
|
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
|
/** A {@linkcode ReadableStream} instance representing to the byte contents
|
||||||
* of the file. This makes it easy to interoperate with other web streams
|
* of the file. This makes it easy to interoperate with other web streams
|
||||||
* based APIs.
|
* based APIs.
|
||||||
|
@ -1973,7 +1964,7 @@ declare namespace Deno {
|
||||||
* resolves to the new position within the resource (bytes from the start).
|
* resolves to the new position within the resource (bytes from the start).
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```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(
|
* using file = await Deno.open(
|
||||||
* "hello.txt",
|
* "hello.txt",
|
||||||
* { read: true, write: true, truncate: true, create: true },
|
* { read: true, write: true, truncate: true, create: true },
|
||||||
|
@ -1991,7 +1982,7 @@ declare namespace Deno {
|
||||||
* The seek modes work as follows:
|
* The seek modes work as follows:
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```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(
|
* const file = await Deno.open(
|
||||||
* "hello.txt",
|
* "hello.txt",
|
||||||
* { read: true, write: true, truncate: true, create: true },
|
* { read: true, write: true, truncate: true, create: true },
|
||||||
|
@ -2028,7 +2019,7 @@ declare namespace Deno {
|
||||||
* The seek modes work as follows:
|
* The seek modes work as follows:
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```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(
|
* using file = Deno.openSync(
|
||||||
* "hello.txt",
|
* "hello.txt",
|
||||||
* { read: true, write: true, truncate: true, create: true },
|
* { read: true, write: true, truncate: true, create: true },
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// 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 {
|
const {
|
||||||
isDate,
|
isDate,
|
||||||
internalRidSymbol,
|
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) {
|
write(p) {
|
||||||
return write(this.#rid, p);
|
return write(this.#rid, p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -783,7 +783,6 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) {
|
||||||
}
|
}
|
||||||
if (internals.future) {
|
if (internals.future) {
|
||||||
delete globalThis.window;
|
delete globalThis.window;
|
||||||
delete Deno.FsFile.prototype.rid;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Warmup
|
// Warmup
|
||||||
|
@ -930,10 +929,6 @@ function bootstrapWorkerRuntime(
|
||||||
nodeDebug,
|
nodeDebug,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (internals.future) {
|
|
||||||
delete Deno.FsFile.prototype.rid;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Warmup
|
// Warmup
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
console.log("window is", globalThis.window);
|
console.log("window is", globalThis.window);
|
||||||
console.log(
|
|
||||||
"Deno.FsFile.prototype.rid is",
|
|
||||||
Deno.openSync(import.meta.filename).rid,
|
|
||||||
);
|
|
||||||
|
|
||||||
// TCP
|
// TCP
|
||||||
// Since these tests may run in parallel, ensure this port is unique to this file
|
// Since these tests may run in parallel, ensure this port is unique to this file
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
window is undefined
|
window is undefined
|
||||||
Deno.FsFile.prototype.rid is undefined
|
|
||||||
Deno.Listener.prototype.rid is undefined
|
Deno.Listener.prototype.rid is undefined
|
||||||
Deno.TlsListener.prototype.rid is undefined
|
Deno.TlsListener.prototype.rid is undefined
|
||||||
Deno.FsFile constructor is illegal
|
Deno.FsFile constructor is illegal
|
||||||
|
|
|
@ -26,7 +26,6 @@ Deno.test(
|
||||||
const filename = "tests/testdata/assets/fixture.json";
|
const filename = "tests/testdata/assets/fixture.json";
|
||||||
using file = await Deno.open(filename);
|
using file = await Deno.open(filename);
|
||||||
assert(file instanceof Deno.FsFile);
|
assert(file instanceof Deno.FsFile);
|
||||||
assert(file.rid > 2);
|
|
||||||
const bytesWritten = await copy(file, Deno.stdout);
|
const bytesWritten = await copy(file, Deno.stdout);
|
||||||
const fileSize = Deno.statSync(filename).size;
|
const fileSize = Deno.statSync(filename).size;
|
||||||
assertEquals(bytesWritten, fileSize);
|
assertEquals(bytesWritten, fileSize);
|
||||||
|
|
|
@ -6,7 +6,6 @@ import {
|
||||||
assertStrictEquals,
|
assertStrictEquals,
|
||||||
assertStringIncludes,
|
assertStringIncludes,
|
||||||
assertThrows,
|
assertThrows,
|
||||||
DENO_FUTURE,
|
|
||||||
} from "./test_util.ts";
|
} from "./test_util.ts";
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
|
@ -363,8 +362,6 @@ Deno.test(
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{
|
{
|
||||||
// Ignoring because uses `file.rid`
|
|
||||||
ignore: DENO_FUTURE,
|
|
||||||
permissions: { run: true, write: true, read: true },
|
permissions: { run: true, write: true, read: true },
|
||||||
},
|
},
|
||||||
async function runRedirectStdoutStderr() {
|
async function runRedirectStdoutStderr() {
|
||||||
|
@ -382,10 +379,12 @@ Deno.test(
|
||||||
"eval",
|
"eval",
|
||||||
"Deno.stderr.write(new TextEncoder().encode('error\\n')); Deno.stdout.write(new TextEncoder().encode('output\\n'));",
|
"Deno.stderr.write(new TextEncoder().encode('error\\n')); Deno.stdout.write(new TextEncoder().encode('output\\n'));",
|
||||||
],
|
],
|
||||||
stdout: file.rid,
|
stdout: "piped",
|
||||||
stderr: file.rid,
|
stderr: "piped",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await p.stdout.readable.pipeTo(file.writable, { preventClose: true });
|
||||||
|
await p.stderr.readable.pipeTo(file.writable);
|
||||||
await p.status();
|
await p.status();
|
||||||
p.close();
|
p.close();
|
||||||
|
|
||||||
|
@ -402,8 +401,6 @@ Deno.test(
|
||||||
|
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{
|
{
|
||||||
// Ignoring because uses `file.rid`
|
|
||||||
ignore: DENO_FUTURE,
|
|
||||||
permissions: { run: true, write: true, read: true },
|
permissions: { run: true, write: true, read: true },
|
||||||
},
|
},
|
||||||
async function runRedirectStdin() {
|
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();
|
const status = await p.status();
|
||||||
assertEquals(status.code, 0);
|
assertEquals(status.code, 0);
|
||||||
p.close();
|
p.close();
|
||||||
|
|
|
@ -75,6 +75,7 @@ Deno.test({
|
||||||
read: true,
|
read: true,
|
||||||
});
|
});
|
||||||
await new Promise<void>((resolve, reject) => {
|
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) => {
|
appendFile(file.rid, "hello world", (err) => {
|
||||||
if (err) reject();
|
if (err) reject();
|
||||||
else resolve();
|
else resolve();
|
||||||
|
@ -166,6 +167,7 @@ Deno.test({
|
||||||
write: true,
|
write: true,
|
||||||
read: true,
|
read: true,
|
||||||
});
|
});
|
||||||
|
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||||
appendFileSync(file.rid, "hello world");
|
appendFileSync(file.rid, "hello world");
|
||||||
const data = Deno.readFileSync(tempFile);
|
const data = Deno.readFileSync(tempFile);
|
||||||
assertEquals(decoder.decode(data), "hello world");
|
assertEquals(decoder.decode(data), "hello world");
|
||||||
|
|
|
@ -13,6 +13,7 @@ Deno.test({
|
||||||
const file: Deno.FsFile = await Deno.open(tempFile);
|
const file: Deno.FsFile = await Deno.open(tempFile);
|
||||||
|
|
||||||
await new Promise<void>((resolve, reject) => {
|
await new Promise<void>((resolve, reject) => {
|
||||||
|
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||||
close(file.rid, (err) => {
|
close(file.rid, (err) => {
|
||||||
if (err !== null) reject();
|
if (err !== null) reject();
|
||||||
else resolve();
|
else resolve();
|
||||||
|
@ -45,6 +46,7 @@ Deno.test({
|
||||||
|
|
||||||
let foo: string;
|
let foo: string;
|
||||||
const promise = new Promise<void>((resolve) => {
|
const promise = new Promise<void>((resolve) => {
|
||||||
|
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||||
close(file.rid, () => {
|
close(file.rid, () => {
|
||||||
assert(foo === "bar");
|
assert(foo === "bar");
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -66,6 +68,7 @@ Deno.test({
|
||||||
const tempFile: string = Deno.makeTempFileSync();
|
const tempFile: string = Deno.makeTempFileSync();
|
||||||
const file: Deno.FsFile = Deno.openSync(tempFile);
|
const file: Deno.FsFile = Deno.openSync(tempFile);
|
||||||
|
|
||||||
|
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||||
closeSync(file.rid);
|
closeSync(file.rid);
|
||||||
Deno.removeSync(tempFile);
|
Deno.removeSync(tempFile);
|
||||||
},
|
},
|
||||||
|
|
|
@ -19,6 +19,7 @@ Deno.test({
|
||||||
await file.write(data);
|
await file.write(data);
|
||||||
|
|
||||||
await new Promise<void>((resolve, reject) => {
|
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) => {
|
fdatasync(file.rid, (err: Error | null) => {
|
||||||
if (err !== null) reject();
|
if (err !== null) reject();
|
||||||
else resolve();
|
else resolve();
|
||||||
|
@ -55,6 +56,7 @@ Deno.test({
|
||||||
file.writeSync(data);
|
file.writeSync(data);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||||
fdatasyncSync(file.rid);
|
fdatasyncSync(file.rid);
|
||||||
assertEquals(Deno.readFileSync(filePath), data);
|
assertEquals(Deno.readFileSync(filePath), data);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -15,6 +15,7 @@ Deno.test({
|
||||||
using file = await Deno.open(filePath);
|
using file = await Deno.open(filePath);
|
||||||
|
|
||||||
await new Promise<Stats>((resolve, reject) => {
|
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) => {
|
fstat(file.rid, (err: Error | null, stat: Stats) => {
|
||||||
if (err) reject(err);
|
if (err) reject(err);
|
||||||
resolve(stat);
|
resolve(stat);
|
||||||
|
@ -43,6 +44,7 @@ Deno.test({
|
||||||
|
|
||||||
await new Promise<BigIntStats>((resolve, reject) => {
|
await new Promise<BigIntStats>((resolve, reject) => {
|
||||||
fstat(
|
fstat(
|
||||||
|
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||||
file.rid,
|
file.rid,
|
||||||
{ bigint: true },
|
{ bigint: true },
|
||||||
(err: Error | null, stat: BigIntStats) => {
|
(err: Error | null, stat: BigIntStats) => {
|
||||||
|
@ -71,6 +73,7 @@ Deno.test({
|
||||||
using file = Deno.openSync(filePath);
|
using file = Deno.openSync(filePath);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||||
assertStats(fstatSync(file.rid), file.statSync());
|
assertStats(fstatSync(file.rid), file.statSync());
|
||||||
} finally {
|
} finally {
|
||||||
Deno.removeSync(filePath);
|
Deno.removeSync(filePath);
|
||||||
|
@ -89,9 +92,11 @@ Deno.test({
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// HEAD
|
// HEAD
|
||||||
|
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||||
assertStatsBigInt(fstatSync(file.rid, { bigint: true }), file.statSync());
|
assertStatsBigInt(fstatSync(file.rid, { bigint: true }), file.statSync());
|
||||||
//
|
//
|
||||||
assertStatsBigInt(
|
assertStatsBigInt(
|
||||||
|
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||||
fstatSync(file.rid, { bigint: true }),
|
fstatSync(file.rid, { bigint: true }),
|
||||||
file.statSync(),
|
file.statSync(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -18,6 +18,7 @@ Deno.test({
|
||||||
await file.truncate(size);
|
await file.truncate(size);
|
||||||
|
|
||||||
await new Promise<void>((resolve, reject) => {
|
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) => {
|
fsync(file.rid, (err: Error | null) => {
|
||||||
if (err !== null) reject();
|
if (err !== null) reject();
|
||||||
else resolve();
|
else resolve();
|
||||||
|
@ -53,6 +54,7 @@ Deno.test({
|
||||||
file.truncateSync(size);
|
file.truncateSync(size);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||||
fsyncSync(file.rid);
|
fsyncSync(file.rid);
|
||||||
assertEquals(Deno.statSync(filePath).size, size);
|
assertEquals(Deno.statSync(filePath).size, size);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -31,6 +31,7 @@ Deno.test({
|
||||||
});
|
});
|
||||||
|
|
||||||
await new Promise<void>((resolve, reject) => {
|
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) => {
|
ftruncate(file.rid, (err: Error | null) => {
|
||||||
if (err !== null) reject();
|
if (err !== null) reject();
|
||||||
else resolve();
|
else resolve();
|
||||||
|
@ -66,6 +67,7 @@ Deno.test({
|
||||||
});
|
});
|
||||||
|
|
||||||
await new Promise<void>((resolve, reject) => {
|
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) => {
|
ftruncate(file.rid, 3, (err: Error | null) => {
|
||||||
if (err !== null) reject();
|
if (err !== null) reject();
|
||||||
else resolve();
|
else resolve();
|
||||||
|
@ -101,6 +103,7 @@ Deno.test({
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||||
ftruncateSync(file.rid);
|
ftruncateSync(file.rid);
|
||||||
const fileInfo: Deno.FileInfo = Deno.lstatSync(filePath);
|
const fileInfo: Deno.FileInfo = Deno.lstatSync(filePath);
|
||||||
assertEquals(fileInfo.size, 0);
|
assertEquals(fileInfo.size, 0);
|
||||||
|
@ -125,6 +128,7 @@ Deno.test({
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||||
ftruncateSync(file.rid, 3);
|
ftruncateSync(file.rid, 3);
|
||||||
const fileInfo: Deno.FileInfo = Deno.lstatSync(filePath);
|
const fileInfo: Deno.FileInfo = Deno.lstatSync(filePath);
|
||||||
assertEquals(fileInfo.size, 3);
|
assertEquals(fileInfo.size, 3);
|
||||||
|
|
|
@ -15,6 +15,7 @@ Deno.test({
|
||||||
using file = await Deno.open(filePath, { create: true, write: true });
|
using file = await Deno.open(filePath, { create: true, write: true });
|
||||||
|
|
||||||
await new Promise<void>((resolve, reject) => {
|
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) => {
|
futimes(file.rid, randomDate, randomDate, (err: Error | null) => {
|
||||||
if (err !== null) reject();
|
if (err !== null) reject();
|
||||||
else resolve();
|
else resolve();
|
||||||
|
@ -73,6 +74,7 @@ Deno.test({
|
||||||
using file = Deno.openSync(filePath, { create: true, write: true });
|
using file = Deno.openSync(filePath, { create: true, write: true });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||||
futimesSync(file.rid, randomDate, randomDate);
|
futimesSync(file.rid, randomDate, randomDate);
|
||||||
|
|
||||||
const fileInfo: Deno.FileInfo = Deno.lstatSync(filePath);
|
const fileInfo: Deno.FileInfo = Deno.lstatSync(filePath);
|
||||||
|
|
|
@ -119,6 +119,7 @@ Deno.test(
|
||||||
});
|
});
|
||||||
|
|
||||||
await new Promise<void>((resolve, reject) => {
|
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) => {
|
writeFile(file.rid, "hello world", (err) => {
|
||||||
if (err) return reject(err);
|
if (err) return reject(err);
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -234,6 +235,7 @@ Deno.test(
|
||||||
});
|
});
|
||||||
|
|
||||||
await new Promise<void>((resolve, reject) => {
|
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) => {
|
writeFile(file.rid, "hello world", { mode: 0o777 }, (err) => {
|
||||||
if (err) return reject(err);
|
if (err) return reject(err);
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -288,6 +290,7 @@ Deno.test(
|
||||||
read: true,
|
read: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||||
writeFileSync(file.rid, "hello world");
|
writeFileSync(file.rid, "hello world");
|
||||||
|
|
||||||
const data = Deno.readFileSync(tempFile);
|
const data = Deno.readFileSync(tempFile);
|
||||||
|
|
|
@ -22,6 +22,7 @@ Deno.test({
|
||||||
});
|
});
|
||||||
const buffer = Buffer.from("hello world");
|
const buffer = Buffer.from("hello world");
|
||||||
const bytesWrite = await new Promise((resolve, reject) => {
|
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) => {
|
write(file.rid, buffer, 0, 5, (err: unknown, nwritten: number) => {
|
||||||
if (err) return reject(err);
|
if (err) return reject(err);
|
||||||
resolve(nwritten);
|
resolve(nwritten);
|
||||||
|
@ -49,6 +50,7 @@ Deno.test({
|
||||||
read: true,
|
read: true,
|
||||||
});
|
});
|
||||||
const buffer = Buffer.from("hello world");
|
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 bytesWrite = writeSync(file.rid, buffer, 0, 5);
|
||||||
|
|
||||||
const data = Deno.readFileSync(tempFile);
|
const data = Deno.readFileSync(tempFile);
|
||||||
|
@ -75,6 +77,7 @@ Deno.test({
|
||||||
|
|
||||||
const str = "hello world";
|
const str = "hello world";
|
||||||
const buffer = Buffer.from(str);
|
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 bytesWritten = writeSync(file.rid, buffer, 0, str.length, 4);
|
||||||
|
|
||||||
const data = Deno.readFileSync(tempFile);
|
const data = Deno.readFileSync(tempFile);
|
||||||
|
@ -122,6 +125,7 @@ Deno.test({
|
||||||
for (let i = 0; i < bytes.length; i++) {
|
for (let i = 0; i < bytes.length; i++) {
|
||||||
buffer[offset + i] = 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 nWritten = writeSync(file.rid, buffer, offset, bytes.length, 0);
|
||||||
|
|
||||||
let data = Deno.readFileSync(tempFile);
|
let data = Deno.readFileSync(tempFile);
|
||||||
|
@ -131,6 +135,7 @@ Deno.test({
|
||||||
assertEquals(data, new Uint8Array(bytes));
|
assertEquals(data, new Uint8Array(bytes));
|
||||||
nWritten = await new Promise((resolve, reject) =>
|
nWritten = await new Promise((resolve, reject) =>
|
||||||
write(
|
write(
|
||||||
|
// @ts-ignore (iuioiua) `file.rid` should no longer be needed once FDs are used
|
||||||
file.rid,
|
file.rid,
|
||||||
buffer,
|
buffer,
|
||||||
offset,
|
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.stdin.isTerminal() === isatty((Deno as any).stdin.rid));
|
||||||
assert(Deno.stdout.isTerminal() === isatty((Deno as any).stdout.rid));
|
assert(Deno.stdout.isTerminal() === isatty((Deno as any).stdout.rid));
|
||||||
assert(Deno.stderr.isTerminal() === isatty((Deno as any).stderr.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", () => {
|
Deno.test("[node/tty isatty] returns false for irrelevant values", () => {
|
||||||
|
|
Loading…
Reference in a new issue