Skip to content

Commit 4c9a7b3

Browse files
committed
chore - deno 2
1 parent 016c0bc commit 4c9a7b3

File tree

10 files changed

+35
-24
lines changed

10 files changed

+35
-24
lines changed

src/core/devconfig.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ export async function reconfigureQuarto(
146146
join(quartoConfig.sharePath(), "..", ".."),
147147
);
148148

149-
const process = Deno.run({
150-
cmd: configureScript,
149+
const process = new Deno.Command(configureScript[0], {
150+
args: configureScript.slice(1),
151151
cwd: quartoDir,
152152
});
153153

154-
await process.status();
154+
await process.output();
155155

156156
info("");
157157
error(

src/core/handlers/dot.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const dotHandler: LanguageHandler = {
7575
console.log = oldConsoleLog;
7676
console.warn = oldConsoleWarn;
7777
} catch (e) {
78+
if (!(e instanceof Error)) throw e;
7879
console.log = oldConsoleLog;
7980
console.warn = oldConsoleWarn;
8081
const m = (e.message as string).match(

src/core/http-server.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/*
2-
* http-server.ts
3-
*
4-
* Copyright (C) 2020-2022 Posit Software, PBC
5-
*
6-
*/
2+
* http-server.ts
3+
*
4+
* Copyright (C) 2020-2022 Posit Software, PBC
5+
*/
76

87
import { warning } from "../deno_ral/log.ts";
98

@@ -18,6 +17,7 @@ export async function handleHttpRequests(
1817
await respondWith(handler(request));
1918
}
2019
} catch (err) {
20+
if (!(err instanceof Error)) throw err;
2121
warning(err.message);
2222
try {
2323
conn.close();

src/core/image.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export function imageSize(path: string) {
2020
width: png.width,
2121
};
2222
} catch (error) {
23+
if (!(error instanceof Error)) throw error;
2324
throw new Error(`Error reading file ${path}\n${error.message}`);
2425
}
2526
}

src/core/jupyter/kernels.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ async function computeJupyterKernelspecs(): Promise<
8080
Map<string, JupyterKernelspec>
8181
> {
8282
try {
83+
const cmd = await jupyterExec();
8384
const result = await execProcess(
8485
{
85-
cmd: [...(await jupyterExec()), "--paths", "--json"],
86+
cmd: cmd[0],
87+
args: [...cmd.slice(1), "--paths", "--json"],
8688
stdout: "piped",
8789
stderr: "piped",
8890
},
@@ -125,6 +127,7 @@ async function computeJupyterKernelspecs(): Promise<
125127
return kDefaultKernelspecs;
126128
}
127129
} catch (e) {
130+
if (!(e instanceof Error)) throw e;
128131
debug("Error reading kernelspecs: " + e.message);
129132
return kDefaultKernelspecs;
130133
}

src/core/jupyter/venv.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export async function jupyterCreateVenv(dir: string, packages?: string[]) {
2323
if (caps) {
2424
const executable = caps.pyLauncher ? "py" : caps.executable;
2525
const result = await execProcess({
26-
cmd: [executable, "-m", "venv", kEnvDir],
26+
cmd: executable,
27+
args: ["-m", "venv", kEnvDir],
2728
cwd: dir,
2829
});
2930
if (!result.success) {
@@ -36,7 +37,8 @@ export async function jupyterCreateVenv(dir: string, packages?: string[]) {
3637
);
3738
packages = ld.uniq(["jupyter"].concat(packages || []));
3839
const installResult = await execProcess({
39-
cmd: [pip3, "install", ...packages],
40+
cmd: pip3,
41+
args: ["install", ...packages],
4042
cwd: dir,
4143
});
4244
if (!installResult.success) {
@@ -55,7 +57,8 @@ export async function jupyterCreateCondaenv(dir: string, packages?: string[]) {
5557
info(`Using conda at ${conda}`);
5658
packages = ld.uniq(["jupyter"].concat(packages || []));
5759
const installResult = await execProcess({
58-
cmd: ["conda", "create", "--yes", "--prefix", "env", ...packages],
60+
cmd: "conda",
61+
args: ["create", "--yes", "--prefix", "env", ...packages],
5962
cwd: dir,
6063
});
6164
if (!installResult.success) {

src/core/lib/markdown-analysis/level-one-headings.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export async function hasLevelOneHeadings(markdown: string): Promise<boolean> {
1717
join("filters", "quarto-internals", "leveloneanalysis.lua"),
1818
);
1919
const result = await execProcess({
20-
cmd: [path, "-f", "markdown", "-t", "markdown", "-L", filterPath],
20+
cmd: path,
21+
args: ["-f", "markdown", "-t", "markdown", "-L", filterPath],
2122
stdout: "piped",
2223
}, markdown);
2324
return result.stdout?.trim() === "true";

src/core/lib/promise.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/*
2-
* promise.ts
3-
*
4-
* Copyright (C) 2020-2022 Posit Software, PBC
5-
*
6-
*/
2+
* promise.ts
3+
*
4+
* Copyright (C) 2020-2022 Posit Software, PBC
5+
*/
76

87
interface PendingPromise<T> {
98
promise: () => Promise<T>;
@@ -56,6 +55,7 @@ export class PromiseQueue<T = unknown> {
5655
this.dequeue();
5756
});
5857
} catch (err) {
58+
if (!(err instanceof Error)) throw err;
5959
this.running = false;
6060
item.reject(err);
6161
this.dequeue();

src/core/lib/yaml-intelligence/annotated-yaml.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ export function readAnnotatedYamlFromMappedString(
109109
}
110110
try {
111111
return buildJsYamlAnnotation(mappedSource);
112-
} catch (e) {
112+
// deno-lint-ignore no-explicit-any
113+
} catch (e: any) {
113114
if (e.name === "YAMLError") {
114115
e.name = "YAML Parsing";
115116
}
@@ -617,6 +618,7 @@ export function locateCursor(
617618
annotation: innermostAnnotation!,
618619
};
619620
} catch (e) {
621+
if (!(e instanceof Error)) throw e;
620622
if (e.message === kInternalLocateError) {
621623
return {
622624
withError: true,

src/core/log.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export function logLevel() {
110110
}
111111

112112
export class StdErrOutputHandler extends BaseHandler {
113-
format(logRecord: LogRecord, prefix = true): string {
113+
override format(logRecord: LogRecord, prefix = true): string {
114114
// Set default options
115115
const options = {
116116
newline: true,
@@ -183,7 +183,7 @@ export class LogEventsHandler extends StdErrOutputHandler {
183183
formatter: (({ msg }) => `${msg}`),
184184
});
185185
}
186-
handle(logRecord: LogRecord) {
186+
override handle(logRecord: LogRecord) {
187187
if (this.level > logRecord.level) return;
188188

189189
LogEventsHandler.handlers_.forEach((handler) =>
@@ -211,11 +211,11 @@ export class LogFileHandler extends FileHandler {
211211
}
212212
msgFormat;
213213

214-
flush(): void {
214+
override flush(): void {
215215
this.logger.flush();
216216
}
217217

218-
format(logRecord: LogRecord): string {
218+
override format(logRecord: LogRecord): string {
219219
// Messages that start with a carriage return are progress messages
220220
// that rewrite a line, so just ignore these
221221
if (logRecord.msg.startsWith("\r")) {
@@ -250,7 +250,7 @@ export class LogFileHandler extends FileHandler {
250250
}
251251
}
252252

253-
async log(msg: string) {
253+
override async log(msg: string) {
254254
// Ignore any messages that are blank
255255
if (msg !== "") {
256256
this.logger.log(msg);

0 commit comments

Comments
 (0)