-
Notifications
You must be signed in to change notification settings - Fork 432
Expand file tree
/
Copy pathpkg-cmd.ts
More file actions
62 lines (54 loc) · 1.71 KB
/
pkg-cmd.ts
File metadata and controls
62 lines (54 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* pkg-cmd.ts
*
* Copyright (C) 2020-2022 Posit Software, PBC
*
*/
import { Command } from "cliffy/command/mod.ts";
import { join } from "../../../src/deno_ral/path.ts";
import { configurationAST, printConfiguration } from "../common/config.ts";
import {
Configuration,
kValidArch,
kValidOS,
readConfiguration,
} from "../common/config.ts";
import { logPandocJson } from "../../../src/core/log.ts";
export const kLogLevel = "logLevel";
export const kVersion = "setVersion";
export function packageCommand(run: (config: Configuration) => Promise<void>) {
return new Command().option(
"-sv, --set-version [version:string]",
"Version to set when preparing this distribution",
).option(
"-o, --os [os:string]",
"Operating system for this command (" + kValidOS.join(", ") + ")",
)
.option(
"-a, --arch [arch:string]",
"Architecture for this command (" + kValidArch.join(", ") + ")",
)
// deno-lint-ignore no-explicit-any
.action(async (args: Record<string, any>) => {
const version = args[kVersion];
const os = args["os"];
const arch = args["arch"];
// Read the version and configuration
const config = readConfiguration(version, os, arch);
// Set up the bin and share environment for any downstream code
Deno.env.set("QUARTO_BIN_PATH", config.directoryInfo.bin);
Deno.env.set(
"QUARTO_SHARE_PATH",
join(config.directoryInfo.src, "resources"),
);
Deno.env.set("QUARTO_DEBUG", "true");
// Print the configuration
try {
await logPandocJson(configurationAST(config));
} catch (e) {
printConfiguration(config);
}
// Run the command
await run(config);
});
}