Skip to content

Commit 47c74f6

Browse files
authored
Merge pull request #11539 from quarto-dev/bugfix/improve-11532-fix
Refactor Deno.build.os into RAL, add safeFileMode
2 parents bf1591b + 68b9884 commit 47c74f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+253
-190
lines changed

news/changelog-1.7.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
All changes included in 1.7:
22

3+
## Regression fixes
34

5+
- ([#11532](https://github.com/quarto-dev/quarto-cli/issues/11532)): Fix regression for [#660](https://github.com/quarto-dev/quarto-cli/issues/660), which causes files to have incorrect permissions when Quarto is installed in a location not writable by the current user.

package/src/common/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { info } from "../../../src/deno_ral/log.ts";
1010

1111
import { getEnv } from "../util/utils.ts";
1212

13+
import { os as platformOs } from "../../../src/deno_ral/platform.ts"
14+
1315
// The core configuration for the packaging process
1416
export interface Configuration extends PlatformConfiguration {
1517
productName: string;
@@ -87,7 +89,7 @@ export function readConfiguration(
8789

8890

8991

90-
const cmdOs = os || getEnv("QUARTO_OS", Deno.build.os);
92+
const cmdOs = os || getEnv("QUARTO_OS", platformOs);
9193
if (!kValidOS.includes(cmdOs)) {
9294
throw new Error(
9395
`Invalid OS ${os} provided. Please use one of ${kValidOS.join(",")}`,

package/src/common/configure.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
} from "./dependencies/dependencies.ts";
2121
import { suggestUserBinPaths } from "../../../src/core/path.ts";
2222
import { buildQuartoPreviewJs } from "../../../src/core/previewjs.ts";
23+
import { isWindows } from "../../../src/deno_ral/platform.ts";
2324

2425
export async function configure(
2526
config: Configuration,
@@ -160,7 +161,7 @@ export function copyPandocScript(config: Configuration, targetDir: string) {
160161
Deno.removeSync(pandocFile);
161162
}
162163

163-
if (Deno.build.os !== "windows") {
164+
if (!isWindows) {
164165
info("> creating pandoc symlink");
165166
Deno.run({
166167
cwd: targetDir,

package/src/util/deno.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
*/
77
import { info } from "../../../src/deno_ral/log.ts";
8+
import { isWindows } from "../../../src/deno_ral/platform.ts";
89
import { Configuration } from "../common/config.ts";
910

1011
export async function bundle(
@@ -132,7 +133,7 @@ export function updateDenoPath(installPath: string, _config: Configuration) {
132133
if (!denoExecPath) {
133134
throw Error("QUARTO_DENO is not defined");
134135
}
135-
const finalTxt = Deno.build.os === "windows"
136+
const finalTxt = isWindows
136137
? installTxt.replace(
137138
/deno.exe /g,
138139
denoExecPath + " ",

package/src/util/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { writeAll } from "io/write-all";
22
import { CmdResult, runCmd } from "./cmd.ts";
3+
import { isWindows } from "../../../src/deno_ral/platform.ts";
34

45
// Read an environment variable
56
export function getEnv(name: string, defaultValue?: string) {
@@ -31,7 +32,7 @@ export async function unzip(
3132
zipFile: string,
3233
dest: string,
3334
): Promise<CmdResult> {
34-
if (Deno.build.os === "windows") {
35+
if (isWindows) {
3536
return await runCmd("PowerShell", [
3637
"Expand-Archive",
3738
"-Path",

src/command/check/check.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { dirname } from "../../deno_ral/path.ts";
4646
import { notebookContext } from "../../render/notebook/notebook-context.ts";
4747
import { typstBinaryPath } from "../../core/typst.ts";
4848
import { quartoCacheDir } from "../../core/appdirs.ts";
49+
import { isWindows } from "../../deno_ral/platform.ts";
4950

5051
const kIndent = " ";
5152

@@ -176,7 +177,7 @@ async function checkInstall(services: RenderServices) {
176177
}
177178
}
178179
info(`${kIndent}Path: ${quartoConfig.binPath()}`);
179-
if (Deno.build.os === "windows") {
180+
if (isWindows) {
180181
try {
181182
const codePage = readCodePage();
182183
clearCodePageCache();

src/command/create/editor.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515

1616
import { basename, dirname, join } from "../../deno_ral/path.ts";
1717
import { existsSync } from "../../deno_ral/fs.ts";
18+
import { isMac, isWindows } from "../../deno_ral/platform.ts";
1819

1920
export interface Editor {
2021
// A short, command line friendly id
@@ -104,7 +105,7 @@ function vscodeEditorInfo(): EditorInfo {
104105
actions: [],
105106
};
106107

107-
if (Deno.build.os === "windows") {
108+
if (isWindows) {
108109
editorInfo.actions.push({
109110
action: "which",
110111
arg: "code.exe",
@@ -118,7 +119,7 @@ function vscodeEditorInfo(): EditorInfo {
118119
},
119120
);
120121
editorInfo.actions.push(...pathActions);
121-
} else if (Deno.build.os === "darwin") {
122+
} else if (isMac) {
122123
editorInfo.actions.push({
123124
action: "which",
124125
arg: "code",
@@ -168,7 +169,7 @@ function positronEditorInfo(): EditorInfo {
168169
actions: [],
169170
};
170171

171-
if (Deno.build.os === "windows") {
172+
if (isWindows) {
172173
editorInfo.actions.push({
173174
action: "which",
174175
arg: "Positron.exe",
@@ -182,7 +183,7 @@ function positronEditorInfo(): EditorInfo {
182183
},
183184
);
184185
editorInfo.actions.push(...pathActions);
185-
} else if (Deno.build.os === "darwin") {
186+
} else if (isMac) {
186187
editorInfo.actions.push({
187188
action: "which",
188189
arg: "positron",
@@ -223,7 +224,7 @@ function rstudioEditorInfo(): EditorInfo {
223224
const rProjPath = join(cwd, `${artifactName}.Rproj`);
224225
Deno.writeTextFileSync(rProjPath, kRProjContents);
225226

226-
const cmd = path.endsWith(".app") && Deno.build.os === "darwin"
227+
const cmd = path.endsWith(".app") && isMac
227228
? ["open", "-na", path, "--args", rProjPath]
228229
: [path, rProjPath];
229230

@@ -239,7 +240,7 @@ function rstudioEditorInfo(): EditorInfo {
239240
};
240241

241242
const rstudioExe = "rstudio.exe";
242-
if (Deno.build.os === "windows") {
243+
if (isWindows) {
243244
editorInfo.actions.push({
244245
action: "env",
245246
arg: "RS_RPOSTBACK_PATH",
@@ -257,7 +258,7 @@ function rstudioEditorInfo(): EditorInfo {
257258
},
258259
);
259260
editorInfo.actions.push(...paths);
260-
} else if (Deno.build.os === "darwin") {
261+
} else if (isMac) {
261262
const paths = macosAppPaths("RStudio.app").map((path) => {
262263
return {
263264
action: "path",

src/command/render/filters.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ import { shortUuid } from "../../core/uuid.ts";
9292
import { isServerShinyPython } from "../../core/render.ts";
9393
import { pythonExec } from "../../core/jupyter/exec.ts";
9494
import { kTocIndent } from "../../config/constants.ts";
95+
import { isWindows } from "../../deno_ral/platform.ts";
9596

9697
const kQuartoParams = "quarto-params";
9798

@@ -700,7 +701,7 @@ async function extensionShortcodes(options: PandocOptions) {
700701

701702
function initFilterParams(dependenciesFile: string) {
702703
const params: Metadata = {};
703-
if (Deno.build.os === "windows") {
704+
if (isWindows) {
704705
const value = readCodePage();
705706
if (value) {
706707
debug("Windows: Using code page " + value);

src/command/render/latexmk/pdf.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
} from "./parse-error.ts";
2727
import { error, info, warning } from "../../../deno_ral/log.ts";
2828
import { logProgress } from "../../../core/log.ts";
29+
import { isWindows } from "../../../deno_ral/platform.ts";
2930

3031
export async function generatePdf(mkOptions: LatexmkOptions): Promise<string> {
3132
if (!mkOptions.quiet) {
@@ -369,7 +370,7 @@ async function makeBibliographyIntermediates(
369370
// If we're on windows and auto-install isn't enabled,
370371
// fix up the aux file
371372
//
372-
if (Deno.build.os === "windows") {
373+
if (isWindows) {
373374
if (bibCommand !== "biber" && !hasTexLive()) {
374375
// See https://github.com/rstudio/tinytex/blob/b2d1bae772f3f979e77fca9fb5efda05855b39d2/R/latex.R#L284
375376
// Strips the '.bib' from any match and returns the string without the bib extension

src/command/render/latexmk/texlive.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { requireQuoting, safeWindowsExec } from "../../../core/windows.ts";
1111
import { hasTinyTex, tinyTexBinDir } from "../../../tools/impl/tinytex-info.ts";
1212
import { join } from "../../../deno_ral/path.ts";
1313
import { logProgress } from "../../../core/log.ts";
14+
import { isWindows } from "../../../deno_ral/platform.ts";
1415

1516
export interface TexLiveContext {
1617
preferTinyTex: boolean;
@@ -438,7 +439,7 @@ function tlmgrCommand(
438439

439440
// On windows, we always want to call tlmgr through the 'safe'
440441
// cmd /c approach since it is a bat file
441-
if (Deno.build.os === "windows") {
442+
if (isWindows) {
442443
const quoted = requireQuoting(args);
443444
return safeWindowsExec(
444445
tlmgr.fullPath,

0 commit comments

Comments
 (0)