Skip to content

Commit 327e949

Browse files
committed
Setup paths before init
1 parent 064f70c commit 327e949

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/swiftly/swiftly.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,35 @@
1-
import { addPath, debug, info } from "@actions/core";
1+
import { addPath, debug, exportVariable, info } from "@actions/core";
22
import { cmd } from "../core";
3+
import { mkdtempSync } from "fs";
4+
import path from "path";
5+
36

47
async function swiftly(...args: string[]) {
58
return await cmd("swiftly", ...args);
69
}
710

11+
function setupPaths() {
12+
const tmpPath = mkdtempSync(`swiftly`);
13+
14+
const homeDir = process.env.SWIFTLY_HOME_DIR || path.join(tmpPath, "home") ;
15+
const binDir = process.env.SWIFTLY_BIN_DIR || path.join(tmpPath, "bin");
16+
17+
exportVariable('SWIFTLY_HOME_DIR', homeDir);
18+
exportVariable('SWIFTLY_BIN_DIR', binDir);
19+
20+
addPath(binDir);
21+
22+
debug(`Using Swiftly home dir: ${homeDir}`);
23+
debug(`Using Swiftly bin dir: ${binDir}`);
24+
}
25+
826
/**
927
* Install Swift using Swiftly
1028
* @param version Version to install
1129
*/
1230
export async function installSwift(version: string) {
31+
setupPaths();
32+
1333
info("Initializing Swiftly");
1434
await swiftly(
1535
"init",

0 commit comments

Comments
 (0)