Skip to content

Commit e20d78d

Browse files
authored
Merge pull request #11351 from tjni/deno2-direct-compat
A few changes for Deno 2 runtime compatibility
2 parents 8d9f858 + 5b9df73 commit e20d78d

File tree

7 files changed

+11
-43
lines changed

7 files changed

+11
-43
lines changed

package/src/util/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function download(src: string, dest: string): Promise<void> {
2525

2626
const file = await Deno.create(dest);
2727
await writeAll(file, contents);
28-
Deno.close(file.rid);
28+
file.close();
2929
}
3030

3131
export async function unzip(

src/core/console.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export function writeFileToStdout(file: string) {
174174
const df = Deno.openSync(file, { read: true });
175175
const contents = readAllSync(df);
176176
writeAllSync(Deno.stdout, contents);
177-
Deno.close(df.rid);
177+
df.close();
178178
}
179179

180180
export function clearLine() {

src/core/performance/metrics.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,37 +41,4 @@ export function reportPeformanceMetrics() {
4141
console.log("Performance metrics");
4242
console.log("Quarto:");
4343
console.log(JSON.stringify(quartoPerformanceMetrics(), null, 2));
44-
console.log();
45-
// denoMetrics is some kind of fancy object that doesn't respond
46-
// to a bunch of the normal methods. So we have to do this
47-
// the JSON-round-trip way.
48-
console.log("Deno:");
49-
const denoMetrics = JSON.parse(JSON.stringify(Deno.metrics() as any));
50-
denoMetrics.ops = Object.fromEntries(
51-
Object.entries(denoMetrics.ops).map(
52-
([key, opMetrics]: any) => {
53-
for (const key of Object.keys(opMetrics)) {
54-
if (opMetrics[key] === 0) {
55-
delete opMetrics[key];
56-
}
57-
}
58-
return [key, opMetrics];
59-
},
60-
).filter(([_key, opMetrics]: any) => Object.keys(opMetrics).length > 0)
61-
.map(([key, opMetrics]: any) => {
62-
if (
63-
(opMetrics.opsDispatched === opMetrics.opsDispatchedSync &&
64-
opMetrics.opsDispatched === opMetrics.opsCompleted &&
65-
opMetrics.opsDispatched === opMetrics.opsCompletedSync) ||
66-
(opMetrics.opsDispatched === opMetrics.opsDispatchedAsync &&
67-
opMetrics.opsDispatched === opMetrics.opsCompleted &&
68-
opMetrics.opsDispatched === opMetrics.opsCompletedAsync)
69-
) {
70-
return [key, opMetrics.opsDispatched];
71-
} else {
72-
return [key, opMetrics];
73-
}
74-
}),
75-
);
76-
console.log(JSON.stringify(denoMetrics, null, 2));
7744
}

src/core/platform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function jupyterHubServicePrefix() {
8787
}
8888

8989
export function isInteractiveTerminal() {
90-
return Deno.isatty(Deno.stderr.rid);
90+
return Deno.stderr.isTerminal();
9191
}
9292

9393
export function isInteractiveSession() {

src/core/process.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { MuxAsyncIterator, pooledMap } from "async";
88
import { iterateReader } from "io/iterate-reader";
9+
import { type Closer, type Reader } from "io/types";
910
import { debug, info } from "../deno_ral/log.ts";
1011
import { onCleanup } from "./cleanup.ts";
1112
import { ProcessResult } from "./process-types.ts";
@@ -104,7 +105,7 @@ export async function execProcess(
104105

105106
// Add streams to the multiplexer
106107
const addStream = (
107-
stream: (Deno.Reader & Deno.Closer) | null,
108+
stream: (Reader & Closer) | null,
108109
filter?: (output: string) => string,
109110
) => {
110111
if (stream !== null) {
@@ -131,7 +132,7 @@ export async function execProcess(
131132
}
132133

133134
// Close the streams
134-
const closeStream = (stream: (Deno.Reader & Deno.Closer) | null) => {
135+
const closeStream = (stream: (Reader & Closer) | null) => {
135136
if (stream) {
136137
stream.close();
137138
}

src/project/types/website/listing/website-listing-feed.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ async function generateFeed(
517517
escape,
518518
},
519519
);
520-
await Deno.write(feedFile.rid, textEncoder.encode(preamble));
520+
await feedFile.write(textEncoder.encode(preamble));
521521

522522
for (const feedItem of feedItems) {
523523
const item = renderEjs(
@@ -527,7 +527,7 @@ async function generateFeed(
527527
escape,
528528
},
529529
);
530-
await Deno.write(feedFile.rid, textEncoder.encode(item));
530+
await feedFile.write(textEncoder.encode(item));
531531
}
532532

533533
// Render the postamble
@@ -538,9 +538,9 @@ async function generateFeed(
538538
escape,
539539
},
540540
);
541-
await Deno.write(feedFile.rid, textEncoder.encode(postamble));
541+
await feedFile.write(textEncoder.encode(postamble));
542542
} finally {
543-
Deno.close(feedFile.rid);
543+
feedFile.close();
544544
}
545545
}
546546

src/publish/common/publish.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ function stageDocumentPublish(title: string, publishFiles: PublishFiles) {
267267
const publishDir = globalTempContext().createDir();
268268

269269
// copy all files to it
270-
const stagedFiles = window.structuredClone(publishFiles) as PublishFiles;
270+
const stagedFiles = globalThis.structuredClone(publishFiles) as PublishFiles;
271271
stagedFiles.baseDir = publishDir;
272272
for (const file of publishFiles.files) {
273273
const src = join(publishFiles.baseDir, file);

0 commit comments

Comments
 (0)