-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ts
More file actions
67 lines (54 loc) · 1.81 KB
/
Copy pathbuild.ts
File metadata and controls
67 lines (54 loc) · 1.81 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
63
64
65
66
67
#!/usr/bin/env -S deno run --allow-read --allow-run --allow-env
// This script reads the version from deno.json and runs the appropriate build commands
// with the version substituted for the $VERSION placeholder
import { join } from "@std/path";
// Read the deno.json file to get the version
const denoJsonPath = join(Deno.cwd(), "deno.json");
const denoJson = JSON.parse(await Deno.readTextFile(denoJsonPath));
const version = denoJson.version;
if (!version) {
console.error("No version found in deno.json");
Deno.exit(1);
}
console.log(`Building version ${version}`);
// Set the VERSION environment variable for the build commands
Deno.env.set("VERSION", version);
// Get the platform-specific command to run
const platform = Deno.args[0] || "all";
async function runCommand(cmd: string[], options: Deno.CommandOptions = {}) {
console.log(`Running: ${cmd.join(" ")}`);
const command = new Deno.Command(cmd[0], {
args: cmd.slice(1),
stdout: "inherit",
stderr: "inherit",
...options
});
const { success } = await command.output();
if (!success) {
console.error(`Command failed: ${cmd.join(" ")}`);
Deno.exit(1);
}
}
// Run the appropriate build command
switch (platform) {
case "local":
await runCommand(["deno", "task", "compile:local"]);
break;
case "win":
await runCommand(["deno", "task", "compile:win"]);
break;
case "mac":
await runCommand(["deno", "task", "compile:mac"]);
break;
case "linux":
await runCommand(["deno", "task", "compile:linux"]);
break;
case "all":
await runCommand(["deno", "task", "compile"]);
break;
default:
console.error(`Unknown platform: ${platform}`);
console.log("Usage: deno run -A build.ts [local|win|mac|linux|all]");
Deno.exit(1);
}
console.log(`Build completed for version ${version}`);