Skip to content

Commit 90cb63a

Browse files
committed
partial work
1 parent 8195e18 commit 90cb63a

34 files changed

Lines changed: 201 additions & 130 deletions

package/src/common/archive-binary-dependencies.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ export async function archiveBinaryDependency(
164164
}
165165

166166
async function s3cmd(cmd: string, args: string[]) {
167-
const s3Command = ["aws", "s3", cmd, ...args];
167+
const s3Args = ["s3", cmd, ...args];
168168
const p = await execProcess({
169-
cmd: s3Command,
169+
cmd: "aws",
170+
args: s3Args,
170171
stdout: "piped",
171172
});
172173

package/src/common/validate-bundle.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export async function validateBundle(
3232
// NPM Install
3333
info("Installing Dependencies");
3434
const npm = await execProcess({
35-
cmd: ["npm", "install"],
35+
cmd: "npm",
36+
args: ["install"],
3637
stderr: "piped"
3738
});
3839
if (!npm.success) {
@@ -53,7 +54,8 @@ export async function validateBundle(
5354
// Test the bundled output
5455
info("Testing Bundled output");
5556
const npx = await execProcess({
56-
cmd: ["npx", "eslint", "bundle.js"],
57+
cmd: "npx",
58+
args: ["eslint", "bundle.js"],
5759
stderr: "piped"
5860

5961
});

package/src/windows/installer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ export async function makeInstallerWindows(configuration: Configuration) {
157157

158158
export function zip(input: string, output: string) {
159159
const dir = dirname(input);
160-
const cmd = [
161-
"powershell",
160+
const cmd = "powershell";
161+
const args = [
162162
"Compress-Archive",
163163
"-Force",
164164
input,
@@ -169,6 +169,7 @@ export function zip(input: string, output: string) {
169169
return execProcess(
170170
{
171171
cmd,
172+
args,
172173
cwd: dir,
173174
stdout: "piped",
174175
},

src/command/create/artifacts/artifact-shared.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ export async function ejsData(
150150

151151
async function gitAuthor() {
152152
const result = await execProcess({
153-
cmd: ["git", "config", "--global", "user.name"],
153+
cmd: "git",
154+
args: ["config", "--global", "user.name"],
154155
stdout: "piped",
155156
stderr: "piped",
156157
});

src/command/editor-support/crossref.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ const makeCrossrefCommand = () => {
9292
Deno.env.set("QUARTO_CROSSREF_INPUT_TYPE", "qmd");
9393

9494
// build command
95-
const cmd = [pandocBinaryPath(), "+RTS", "-K512m", "-RTS"];
96-
cmd.push(...[
95+
const cmd = pandocBinaryPath();
96+
const cmdArgs = ["+RTS", "-K512m", "-RTS"];
97+
cmdArgs.push(...[
9798
"--from",
9899
resourcePath("filters/qmd-reader.lua"),
99100
"--to",
@@ -118,6 +119,7 @@ const makeCrossrefCommand = () => {
118119
const result = await execProcess(
119120
{
120121
cmd,
122+
args: cmdArgs,
121123
cwd: indexingDir,
122124
env: {
123125
"QUARTO_FILTER_PARAMS": filterParams,

src/command/render/latexmk/latex.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { error, info } from "../../../deno_ral/log.ts";
1111
import { PdfEngine } from "../../../config/types.ts";
1212

1313
import { dirAndStem } from "../../../core/path.ts";
14-
import { execProcess } from "../../../core/process.ts";
14+
import { execProcess, ExecProcessOptions } from "../../../core/process.ts";
1515
import { ProcessResult } from "../../../core/process-types.ts";
1616

1717
import { PackageManager } from "./pkgmgr.ts";
@@ -29,7 +29,8 @@ export interface LatexCommandReponse {
2929
export async function hasLatexDistribution() {
3030
try {
3131
const result = await execProcess({
32-
cmd: ["pdftex", "--version"],
32+
cmd: "pdftex",
33+
args: ["--version"],
3334
stdout: "piped",
3435
stderr: "piped",
3536
});
@@ -211,8 +212,9 @@ async function runLatexCommand(
211212
): Promise<ProcessResult> {
212213
const fullLatexCmd = texLiveCmd(latexCmd, context.texLive);
213214

214-
const runOptions: Deno.RunOptions = {
215-
cmd: [fullLatexCmd.fullPath, ...args],
215+
const runOptions: ExecProcessOptions = {
216+
cmd: fullLatexCmd.fullPath,
217+
args,
216218
stdout: "piped",
217219
stderr: "piped",
218220
};

src/command/render/latexmk/texlive.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,8 @@ function tlmgrCommand(
427427
const execTlmgr = (tlmgrCmd: string[]) => {
428428
return execProcess(
429429
{
430-
cmd: tlmgrCmd,
430+
cmd: tlmgrCmd[0],
431+
args: tlmgrCmd.slice(1),
431432
stdout: "piped",
432433
stderr: "piped",
433434
},
@@ -457,7 +458,8 @@ function fmtutilCommand(context: TexLiveContext) {
457458
const fmtutil = texLiveCmd("fmtutil-sys", context);
458459
return execProcess(
459460
{
460-
cmd: [fmtutil.fullPath, "--all"],
461+
cmd: fmtutil.fullPath,
462+
args: ["--all"],
461463
stdout: "piped",
462464
stderr: "piped",
463465
},

src/command/render/output-tex.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,12 @@ export function contextPdfOutputRecipe(
179179
const engine = pdfEngine(format.pandoc, format.render, pandocOptions.flags);
180180

181181
// build context command
182-
const cmd = ["context", input];
182+
const cmd = "context";
183+
const args = [input];
183184
if (engine.pdfEngineOpts) {
184-
cmd.push(...engine.pdfEngineOpts);
185+
args.push(...engine.pdfEngineOpts);
185186
}
186-
cmd.push(
187+
args.push(
187188
// ConTeXt produces some auxiliary files:
188189
// direct PDF generation by Pandoc never produces these auxiliary
189190
// files because Pandoc runs ConTeXt in a temporary directory.
@@ -194,7 +195,10 @@ export function contextPdfOutputRecipe(
194195
);
195196

196197
// run context
197-
const result = await execProcess({ cmd });
198+
const result = await execProcess({
199+
cmd,
200+
args,
201+
});
198202
if (result.success) {
199203
const [dir, stem] = dirAndStem(input);
200204
return computePath(stem, dir, format);

src/command/render/pandoc.ts

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -241,42 +241,38 @@ const handleCombinedLuaProfiles = (
241241
};
242242

243243
function captureRenderCommand(
244-
args: Deno.RunOptions,
244+
args: Deno.CommandOptions,
245245
temp: TempContext,
246246
outputDir: string,
247247
) {
248248
Deno.mkdirSync(outputDir, { recursive: true });
249-
const newArgs = [
250-
args.cmd[0],
251-
...args.cmd.slice(1).map((_arg) => {
252-
const arg = _arg as string; // we know it's a string, TypeScript doesn't somehow
253-
if (!arg.startsWith(temp.baseDir)) {
254-
return arg;
255-
}
256-
const newArg = join(outputDir, basename(arg));
257-
if (arg.match(/^.*quarto\-defaults.*.yml$/)) {
258-
// we need to correct the defaults YML because it contains a reference to a template in a temp directory
259-
const ymlDefaults = Deno.readTextFileSync(arg);
260-
const defaults = parseYml(ymlDefaults);
261-
262-
const templateDirectory = dirname(defaults.template);
263-
const newTemplateDirectory = join(
264-
outputDir,
265-
basename(templateDirectory),
266-
);
267-
copyTo(templateDirectory, newTemplateDirectory);
268-
defaults.template = join(
269-
newTemplateDirectory,
270-
basename(defaults.template),
271-
);
272-
const defaultsOutputFile = join(outputDir, basename(arg));
273-
Deno.writeTextFileSync(defaultsOutputFile, stringify(defaults));
274-
return defaultsOutputFile;
275-
}
276-
Deno.copyFileSync(arg, newArg);
277-
return newArg;
278-
}),
279-
] as typeof args.cmd;
249+
const newArgs: typeof args.args = (args.args ?? []).map((_arg) => {
250+
const arg = _arg as string; // we know it's a string, TypeScript doesn't somehow
251+
if (!arg.startsWith(temp.baseDir)) {
252+
return arg;
253+
}
254+
const newArg = join(outputDir, basename(arg));
255+
if (arg.match(/^.*quarto\-defaults.*.yml$/)) {
256+
// we need to correct the defaults YML because it contains a reference to a template in a temp directory
257+
const ymlDefaults = Deno.readTextFileSync(arg);
258+
const defaults = parseYml(ymlDefaults);
259+
const templateDirectory = dirname(defaults.template);
260+
const newTemplateDirectory = join(
261+
outputDir,
262+
basename(templateDirectory),
263+
);
264+
copyTo(templateDirectory, newTemplateDirectory);
265+
defaults.template = join(
266+
newTemplateDirectory,
267+
basename(defaults.template),
268+
);
269+
const defaultsOutputFile = join(outputDir, basename(arg));
270+
Deno.writeTextFileSync(defaultsOutputFile, stringify(defaults));
271+
return defaultsOutputFile;
272+
}
273+
Deno.copyFileSync(arg, newArg);
274+
return newArg;
275+
});
280276

281277
// now we need to correct entries in filterParams
282278
const filterParams = JSON.parse(
@@ -1322,7 +1318,8 @@ export async function runPandoc(
13221318
setupPandocEnv();
13231319

13241320
const params = {
1325-
cmd,
1321+
cmd: cmd[0],
1322+
args: cmd.slice(1),
13261323
cwd,
13271324
env: pandocEnv,
13281325
ourEnv: Deno.env.toObject(),

src/command/render/project.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,8 @@ async function runScripts(
994994
}
995995
} else {
996996
const result = await execProcess({
997-
cmd: args,
997+
cmd: args[0],
998+
args: args.slice(1),
998999
cwd: projDir,
9991000
stdout: quiet ? "piped" : "inherit",
10001001
env,

0 commit comments

Comments
 (0)