Skip to content

Commit

Permalink
chore: soft-remove Deno.{stdin,stderr,stdout}.rid (#25479)
Browse files Browse the repository at this point in the history
Towards #22079
  • Loading branch information
iuioiua authored Sep 6, 2024
1 parent 292344a commit 5bac407
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 46 deletions.
27 changes: 0 additions & 27 deletions cli/tsc/dts/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2468,15 +2468,6 @@ declare namespace Deno {
* @category I/O
*/
export const stdin: Reader & ReaderSync & Closer & {
/**
* The resource ID assigned to `stdin`. This can be used with the discrete
* I/O functions in the `Deno` namespace.
*
* @deprecated This will be soft-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 readable stream interface to `stdin`. */
readonly readable: ReadableStream<Uint8Array>;
/**
Expand Down Expand Up @@ -2516,15 +2507,6 @@ declare namespace Deno {
* @category I/O
*/
export const stdout: Writer & WriterSync & Closer & {
/**
* The resource ID assigned to `stdout`. This can be used with the discrete
* I/O functions in the `Deno` namespace.
*
* @deprecated This will be soft-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 writable stream interface to `stdout`. */
readonly writable: WritableStream<Uint8Array>;
/**
Expand All @@ -2550,15 +2532,6 @@ declare namespace Deno {
* @category I/O
*/
export const stderr: Writer & WriterSync & Closer & {
/**
* The resource ID assigned to `stderr`. This can be used with the discrete
* I/O functions in the `Deno` namespace.
*
* @deprecated This will be soft-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 writable stream interface to `stderr`. */
readonly writable: WritableStream<Uint8Array>;
/**
Expand Down
17 changes: 1 addition & 16 deletions ext/io/12_io.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Documentation liberally lifted from them too.
// Thank you! We love Go! <3

import { core, internals, primordials } from "ext:core/mod.js";
import { core, primordials } from "ext:core/mod.js";
import { op_set_raw } from "ext:core/ops";
const {
Uint8Array,
Expand Down Expand Up @@ -121,11 +121,6 @@ class Stdin {
}

get rid() {
internals.warnOnDeprecatedApi(
"Deno.stdin.rid",
new Error().stack,
"Use `Deno.stdin` instance methods instead.",
);
return this.#rid;
}

Expand Down Expand Up @@ -186,11 +181,6 @@ class Stdout {
}

get rid() {
internals.warnOnDeprecatedApi(
"Deno.stdout.rid",
new Error().stack,
"Use `Deno.stdout` instance methods instead.",
);
return this.#rid;
}

Expand Down Expand Up @@ -226,11 +216,6 @@ class Stderr {
}

get rid() {
internals.warnOnDeprecatedApi(
"Deno.stderr.rid",
new Error().stack,
"Use `Deno.stderr` instance methods instead.",
);
return this.#rid;
}

Expand Down
3 changes: 3 additions & 0 deletions tests/unit/files_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ import { copy } from "@std/io/copy";
// Note tests for Deno.FsFile.setRaw is in integration tests.

Deno.test(function filesStdioFileDescriptors() {
// @ts-ignore `Deno.stdin.rid` was soft-removed in Deno 2.
assertEquals(Deno.stdin.rid, 0);
// @ts-ignore `Deno.stdout.rid` was soft-removed in Deno 2.
assertEquals(Deno.stdout.rid, 1);
// @ts-ignore `Deno.stderr.rid` was soft-removed in Deno 2.
assertEquals(Deno.stderr.rid, 2);
});

Expand Down
3 changes: 3 additions & 0 deletions tests/unit_node/process_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ Deno.test({
Deno.test({
name: "process.stdin",
fn() {
// @ts-ignore `Deno.stdin.rid` was soft-removed in Deno 2.
assertEquals(process.stdin.fd, Deno.stdin.rid);
assertEquals(process.stdin.isTTY, Deno.stdin.isTerminal());
},
Expand Down Expand Up @@ -640,6 +641,7 @@ Deno.test({
Deno.test({
name: "process.stdout",
fn() {
// @ts-ignore `Deno.stdout.rid` was soft-removed in Deno 2.
assertEquals(process.stdout.fd, Deno.stdout.rid);
const isTTY = Deno.stdout.isTerminal();
assertEquals(process.stdout.isTTY, isTTY);
Expand Down Expand Up @@ -668,6 +670,7 @@ Deno.test({
Deno.test({
name: "process.stderr",
fn() {
// @ts-ignore `Deno.stderr.rid` was soft-removed in Deno 2.
assertEquals(process.stderr.fd, Deno.stderr.rid);
const isTTY = Deno.stderr.isTerminal();
assertEquals(process.stderr.isTTY, isTTY);
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_node/tty_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import tty from "node:tty";
import process from "node:process";

Deno.test("[node/tty isatty] returns true when fd is a tty, false otherwise", () => {
assert(Deno.stdin.isTerminal() === isatty(Deno.stdin.rid));
assert(Deno.stdout.isTerminal() === isatty(Deno.stdout.rid));
assert(Deno.stderr.isTerminal() === isatty(Deno.stderr.rid));
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));
Expand Down

0 comments on commit 5bac407

Please sign in to comment.