Skip to content

Commit 811cc07

Browse files
authored
Merge branch 'main' into latex/auto-install-opt-out
2 parents 1c862a1 + bb29023 commit 811cc07

4 files changed

Lines changed: 80 additions & 2 deletions

File tree

news/changelog-1.6.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ All changes included in 1.6:
2626
- For default behavior (`latex-auto-install: true`), detection is still happening and missing packages are installed automatically. If it fails, Quarto does not fail anymore as PDF rendering as succeeded already. Only a warning will be thrown to log the installation failure.
2727
- Log message about hyphenation package missing for `chinese` or `chinese-hans` languages are now ignored.
2828

29+
## Projects
30+
31+
- ([#10268](https://github.com/quarto-dev/quarto-cli/issues/10268)]): `quarto create` supports opening project in Positron, in addition to VS Code and RStudio IDE.
32+
2933
## Engines
3034

3135
### `julia`

src/command/create/cmd.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const createCommand = new Command()
3030
.option(
3131
"--open [editor:string]",
3232
`Open new artifact in this editor (${
33-
kEditorInfos.map((info) => info.id).join(",")
33+
kEditorInfos.map((info) => info.id).join(", ")
3434
})`,
3535
)
3636
.option("--no-open", "Do not open in an editor")

src/command/create/editor.ts

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
import { CreateResult } from "./cmd-types.ts";
88

99
import { which } from "../../core/path.ts";
10-
import { isRStudioTerminal, isVSCodeTerminal } from "../../core/platform.ts";
10+
import {
11+
isPositronTerminal,
12+
isRStudioTerminal,
13+
isVSCodeTerminal,
14+
} from "../../core/platform.ts";
1115

1216
import { basename, dirname, join } from "../../deno_ral/path.ts";
1317
import { existsSync } from "fs/mod.ts";
@@ -29,6 +33,7 @@ export interface Editor {
2933
}
3034

3135
export const kEditorInfos: EditorInfo[] = [
36+
positronEditorInfo(),
3237
vscodeEditorInfo(),
3338
rstudioEditorInfo(),
3439
];
@@ -141,6 +146,66 @@ function vscodeEditorInfo(): EditorInfo {
141146
return editorInfo;
142147
}
143148

149+
function positronEditorInfo(): EditorInfo {
150+
const editorInfo: EditorInfo = {
151+
id: "positron",
152+
name: "positron",
153+
open: (path: string, createResult: CreateResult) => {
154+
const artifactPath = createResult.path;
155+
const cwd = Deno.statSync(artifactPath).isDirectory
156+
? artifactPath
157+
: dirname(artifactPath);
158+
159+
return async () => {
160+
const p = Deno.run({
161+
cmd: [path, artifactPath],
162+
cwd,
163+
});
164+
await p.status();
165+
};
166+
},
167+
inEditor: isPositronTerminal(),
168+
actions: [],
169+
};
170+
171+
if (Deno.build.os === "windows") {
172+
editorInfo.actions.push({
173+
action: "which",
174+
arg: "Positron.exe",
175+
});
176+
const pathActions = windowsAppPaths("Positron", "Positron.exe").map(
177+
(path) => {
178+
return {
179+
action: "path",
180+
arg: path,
181+
} as ScanAction;
182+
},
183+
);
184+
editorInfo.actions.push(...pathActions);
185+
} else if (Deno.build.os === "darwin") {
186+
editorInfo.actions.push({
187+
action: "which",
188+
arg: "positron",
189+
});
190+
191+
const pathActions = macosAppPaths(
192+
"Positron.app/Contents/Resources/app/bin/code",
193+
).map((path) => {
194+
return {
195+
action: "path",
196+
arg: path,
197+
} as ScanAction;
198+
});
199+
editorInfo.actions.push(...pathActions);
200+
} else {
201+
editorInfo.actions.push({
202+
action: "which",
203+
arg: "positron",
204+
});
205+
}
206+
return editorInfo;
207+
}
208+
144209
function rstudioEditorInfo(): EditorInfo {
145210
const editorInfo: EditorInfo = {
146211
id: "rstudio",

src/core/platform.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ export function isRStudio() {
2424
return !!Deno.env.get("RSTUDIO");
2525
}
2626

27+
export function isPositron() {
28+
return !!Deno.env.get("POSITRON");
29+
}
30+
2731
export function isVSCodeOutputChannel() {
2832
return !!Deno.env.get("VSCODE_PID");
2933
}
@@ -46,6 +50,11 @@ export function isRStudioTerminal() {
4650
return !!Deno.env.get("RSTUDIO_TERM");
4751
}
4852

53+
export function isPositronTerminal() {
54+
// it seems there is no POSITRON_TERM variable set
55+
return isPositron();
56+
}
57+
4958
export function isServerSession() {
5059
return isRStudioServer() || isRStudioWorkbench() || isJupyterServer() ||
5160
isJupyterHubServer() || isVSCodeServer();

0 commit comments

Comments
 (0)