Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deno - replace deprecated Deno.run with Deno.Command #8893

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package/src/common/archive-binary-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ export async function archiveBinaryDependency(

async function s3cmd(cmd: string, args: string[]) {
const s3Command = ["aws", "s3", cmd, ...args];
const p = await execProcess({
cmd: s3Command,
const p = await execProcess(s3Command[0], {
args: s3Command.slice(1),
stdout: "piped",
});

Expand Down
8 changes: 4 additions & 4 deletions package/src/common/validate-bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export async function validateBundle(

// NPM Install
info("Installing Dependencies");
const npm = await execProcess({
cmd: ["npm", "install"],
const npm = await execProcess("npm", {
args: ["install"],
stderr: "piped"
});
if (!npm.success) {
Expand All @@ -52,8 +52,8 @@ export async function validateBundle(

// Test the bundled output
info("Testing Bundled output");
const npx = await execProcess({
cmd: ["npx", "eslint", "bundle.js"],
const npx = await execProcess("npx", {
args: ["eslint", "bundle.js"],
stderr: "piped"

});
Expand Down
7 changes: 3 additions & 4 deletions package/src/windows/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,16 @@ export async function makeInstallerWindows(configuration: Configuration) {
export function zip(input: string, output: string) {
const dir = dirname(input);
const cmd = [
"powershell",
"Compress-Archive",
"-Force",
input,
"-DestinationPath",
output,
];
info(cmd);
return execProcess(
info(["powershell", ...cmd]);
return execProcess("powershell",
{
cmd,
args: cmd,
cwd: dir,
stdout: "piped",
},
Expand Down
4 changes: 2 additions & 2 deletions src/command/check/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ async function checkVersions(_services: RenderServices) {
completeMessage("Checking versions of quarto binary dependencies...");

let pandocVersion = lines(
(await execProcess({
cmd: [pandocBinaryPath(), "--version"],
(await execProcess(pandocBinaryPath(), {
args: ["--version"],
stdout: "piped",
})).stdout!,
)[0]?.split(" ")[1];
Expand Down
4 changes: 2 additions & 2 deletions src/command/create/artifacts/artifact-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ export async function ejsData(
}

async function gitAuthor() {
const result = await execProcess({
cmd: ["git", "config", "--global", "user.name"],
const result = await execProcess("git", {
args: ["config", "--global", "user.name"],
stdout: "piped",
stderr: "piped",
});
Expand Down
13 changes: 5 additions & 8 deletions src/command/create/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,8 @@ function vscodeEditorInfo(): EditorInfo {
: dirname(artifactPath);

return async () => {
const p = Deno.run({
cmd: [path, artifactPath],
cwd,
});
await p.status();
const command = new Deno.Command(path, { cwd, args: [artifactPath] });
await command.output();
};
},
inEditor: isVSCodeTerminal(),
Expand Down Expand Up @@ -162,11 +159,11 @@ function rstudioEditorInfo(): EditorInfo {
? ["open", "-na", path, "--args", rProjPath]
: [path, rProjPath];

const p = Deno.run({
cmd,
const command = new Deno.Command(cmd[0], {
args: cmd.slice(1),
cwd,
});
await p.status();
await command.output();
};
},
inEditor: isRStudioTerminal(),
Expand Down
19 changes: 8 additions & 11 deletions src/command/editor-support/crossref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,15 @@ const makeCrossrefCommand = () => {
);

// run pandoc
const result = await execProcess(
{
cmd,
cwd: indexingDir,
env: {
"QUARTO_FILTER_PARAMS": filterParams,
"QUARTO_SHARE_PATH": resourcePath(),
},
stdout: "piped",
const result = await execProcess(cmd[0], {
args: cmd.slice(1),
cwd: indexingDir,
env: {
"QUARTO_FILTER_PARAMS": filterParams,
"QUARTO_SHARE_PATH": resourcePath(),
},
input,
);
stdout: "piped",
}, input);

// check for error
if (!result.success) {
Expand Down
30 changes: 19 additions & 11 deletions src/command/render/latexmk/latex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export interface LatexCommandReponse {

export async function hasLatexDistribution() {
try {
const result = await execProcess({
cmd: ["pdftex", "--version"],
const result = await execProcess("pdftex", {
args: ["--version"],
stdout: "piped",
stderr: "piped",
});
Expand Down Expand Up @@ -211,36 +211,44 @@ async function runLatexCommand(
): Promise<ProcessResult> {
const fullLatexCmd = texLiveCmd(latexCmd, context.texLive);

const runOptions: Deno.RunOptions = {
cmd: [fullLatexCmd.fullPath, ...args],
const cmd = fullLatexCmd.fullPath;
const commandOptions: Deno.CommandOptions = {
args,
stdout: "piped",
stderr: "piped",
};

//Ensure that the bin directory is available as a part of PDF compilation
if (context.texLive.binDir) {
runOptions.env = runOptions.env || {};
runOptions.env["PATH"] = withPath({ prepend: [context.texLive.binDir] });
commandOptions.env = commandOptions.env || {};
commandOptions.env["PATH"] = withPath({
prepend: [context.texLive.binDir],
});
}

// Set the working directory
if (context.cwd) {
runOptions.cwd = context.cwd;
commandOptions.cwd = context.cwd;
}

// Add a tex search path
// The // means that TeX programs will search recursively in that folder;
// the trailing colon means "append the standard value of TEXINPUTS" (which you don't need to provide).
if (context.texInputDirs && context.texInputDirs.length > 0) {
// note this //
runOptions.env = runOptions.env || {};
runOptions.env["TEXINPUTS"] = `${context.texInputDirs.join(";")};`;
runOptions.env["BSTINPUTS"] = `${context.texInputDirs.join(";")};`;
commandOptions.env = commandOptions.env || {};
commandOptions.env["TEXINPUTS"] = `${context.texInputDirs.join(";")};`;
commandOptions.env["BSTINPUTS"] = `${context.texInputDirs.join(";")};`;
}

// Run the command
const runCmd = async () => {
const result = await execProcess(runOptions, undefined, "stdout>stderr");
const result = await execProcess(
cmd,
commandOptions,
undefined,
"stdout>stderr",
);
if (!quiet && result.stderr) {
info(result.stderr, kLatexBodyMessageOptions);
}
Expand Down
24 changes: 10 additions & 14 deletions src/command/render/latexmk/texlive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,11 @@ function tlmgrCommand(
_quiet?: boolean,
) {
const execTlmgr = (tlmgrCmd: string[]) => {
return execProcess(
{
cmd: tlmgrCmd,
stdout: "piped",
stderr: "piped",
},
);
return execProcess(tlmgrCmd[0], {
args: tlmgrCmd.slice(1),
stdout: "piped",
stderr: "piped",
});
};

// If TinyTex is here, prefer that
Expand All @@ -450,11 +448,9 @@ function tlmgrCommand(
// https://tug.org/texlive/doc/fmtutil.html
function fmtutilCommand(context: TexLiveContext) {
const fmtutil = texLiveCmd("fmtutil-sys", context);
return execProcess(
{
cmd: [fmtutil.fullPath, "--all"],
stdout: "piped",
stderr: "piped",
},
);
return execProcess(fmtutil.fullPath, {
args: ["--all"],
stdout: "piped",
stderr: "piped",
});
}
2 changes: 1 addition & 1 deletion src/command/render/output-tex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export function contextPdfOutputRecipe(
);

// run context
const result = await execProcess({ cmd });
const result = await execProcess(cmd[0], { args: cmd.slice(1) });
if (result.success) {
const [dir, stem] = dirAndStem(input);
return computePath(stem, dir, format);
Expand Down
12 changes: 5 additions & 7 deletions src/command/render/pandoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1165,13 +1165,11 @@ export async function runPandoc(
}

// run pandoc
const result = await execProcess(
{
cmd,
cwd,
env: pandocEnv,
},
);
const result = await execProcess(cmd[0], {
args: cmd.slice(1),
cwd,
env: pandocEnv,
});

// run afterPandoc hooks
for (const hook of afterPandocHooks) {
Expand Down
4 changes: 2 additions & 2 deletions src/command/render/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,8 @@ async function runScripts(
throw new Error();
}
} else {
const result = await execProcess({
cmd: args,
const result = await execProcess(args[0], {
args: args.slice(1),
cwd: projDir,
stdout: quiet ? "piped" : "inherit",
env,
Expand Down
15 changes: 5 additions & 10 deletions src/command/use/commands/binder/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,11 @@ export const useBinderCommand = new Command()

const rConfig: RConfiguration = {};
if (projectHasR(context, projEnv)) {
const result = await execProcess(
{
cmd: [
await rBinaryPath("R"),
"--version",
],
stdout: "piped",
stderr: "piped",
},
);
const result = await execProcess(await rBinaryPath("R"), {
args: ["--version"],
stdout: "piped",
stderr: "piped",
});
if (result.success) {
const output = result.stdout;
const verMatch = output?.match(
Expand Down
27 changes: 16 additions & 11 deletions src/core/bibliography.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ export async function renderHtml(entry: CSL, csl?: string) {
}

const cslStr = JSON.stringify([entry], undefined, 2);
const result = await execProcess(
{ cmd, stdout: "piped", stderr: "piped" },
cslStr,
);
const result = await execProcess(cmd[0], {
args: cmd.slice(1),
stdout: "piped",
stderr: "piped",
}, cslStr);
if (result.success) {
return result.stdout;
} else {
Expand All @@ -62,10 +63,11 @@ export async function renderBibTex(entry: CSL) {
cmd.push("--citeproc");

const cslStr = JSON.stringify([entry], undefined, 2);
const result = await execProcess(
{ cmd, stdout: "piped", stderr: "piped" },
cslStr,
);
const result = await execProcess(cmd[0], {
args: cmd.slice(1),
stdout: "piped",
stderr: "piped",
}, cslStr);
if (result.success) {
return result.stdout;
} else {
Expand All @@ -92,9 +94,12 @@ export async function renderToCSLJSON(
cmd.push("csljson");
cmd.push("--citeproc");

const result = await execProcess(
{ cmd, stdout: "piped", stderr: "piped", cwd: dir },
);
const result = await execProcess(cmd[0], {
args: cmd.slice(1),
stdout: "piped",
stderr: "piped",
cwd: dir,
});
if (result.success) {
if (result.stdout) {
const entries = JSON.parse(result.stdout);
Expand Down
16 changes: 5 additions & 11 deletions src/core/dart-sass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,12 @@ export async function dartCommand(args: string[]) {
};
const sass = resolvePath();

const cmd = [
sass,
...args,
];
// Run the sass compiler
const result = await execProcess(
{
cmd,
stdout: "piped",
stderr: "piped",
},
);
const result = await execProcess(sass, {
args,
stdout: "piped",
stderr: "piped",
});

if (result.success) {
if (result.stderr) {
Expand Down
7 changes: 3 additions & 4 deletions src/core/devconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,11 @@ export async function reconfigureQuarto(
join(quartoConfig.sharePath(), "..", ".."),
);

const process = Deno.run({
cmd: configureScript,
const process = new Deno.Command(configureScript[0], {
args: configureScript.slice(1),
cwd: quartoDir,
});

await process.status();
await process.output();

info("");
error(
Expand Down
8 changes: 2 additions & 6 deletions src/core/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@ export async function esbuildCommand(
input: string,
workingDir: string,
) {
const cmd = [
Deno.env.get("QUARTO_ESBUILD") || architectureToolsPath("esbuild"),
...args,
];

const result = await execProcess(
Deno.env.get("QUARTO_ESBUILD") || architectureToolsPath("esbuild"),
{
cmd,
args,
cwd: workingDir,
stdout: "piped",
},
Expand Down
Loading
Loading