Skip to content

Commit c0c7d91

Browse files
committed
Support post-install script
1 parent 2ab9ed5 commit c0c7d91

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/swiftly/swiftly.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { addPath, debug, exportVariable, info } from "@actions/core";
22
import { cmd } from "../core";
3-
import { mkdtempSync } from "fs";
3+
import { existsSync, mkdtempSync } from "fs";
44
import { join } from "path";
55
import { tmpdir } from "os";
66

@@ -21,14 +21,16 @@ function setupPaths() {
2121

2222
debug(`Using Swiftly home dir: ${homeDir}`);
2323
debug(`Using Swiftly bin dir: ${binDir}`);
24+
25+
return tmpPath;
2426
}
2527

2628
/**
2729
* Install Swift using Swiftly
2830
* @param version Version to install
2931
*/
3032
export async function installSwift(version: string) {
31-
setupPaths();
33+
const tmpPath = setupPaths();
3234

3335
info("Initializing Swiftly");
3436
await swiftly(
@@ -39,8 +41,24 @@ export async function installSwift(version: string) {
3941
"--no-modify-profile",
4042
);
4143

44+
// Sometimes Swiftly needs to perform additional actions after installation
45+
const postInstallScriptPath = join(tmpPath, "post-install.sh");
46+
4247
info(`Installing Swift ${version}`);
43-
await swiftly("install", "--use", version, "--assume-yes");
48+
await swiftly(
49+
"install",
50+
"--use",
51+
version,
52+
"--assume-yes",
53+
"--post-install-script",
54+
postInstallScriptPath,
55+
);
56+
57+
// Run the post-install script if it exists
58+
if (existsSync(postInstallScriptPath)) {
59+
info("Running post-install script");
60+
await cmd("bash", postInstallScriptPath);
61+
}
4462

4563
const location = await swiftly("use", "--print-location");
4664
debug(`Swiftly installed Swift to ${location}`);

0 commit comments

Comments
 (0)