-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsetup-cocoapods.ts
32 lines (26 loc) · 1.19 KB
/
setup-cocoapods.ts
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
import * as core from "@actions/core";
import { CocoapodsInstaller } from "./installer";
import { getVersionFromPodfile } from "./podfile-parser";
const run = async (): Promise<void> => {
try {
if (process.platform !== "darwin" && process.platform !== "linux") {
throw new Error(`This task is intended for macOS and linux platforms. It can't be run on '${process.platform}' platform`);
}
let versionSpec = core.getInput("version", { required: false });
const podfilePath = core.getInput("podfile-path", { required: false });
if (!!versionSpec === !!podfilePath) {
throw new Error("Invalid input parameters usage. Either 'version' or 'podfile-path' should be specified. Not the both ones.");
}
if (!versionSpec) {
core.debug("Reading Podfile to determine the version of Cocoapods...");
versionSpec = getVersionFromPodfile(podfilePath);
core.info(`Podfile points to the Cocoapods ${versionSpec}`);
}
await CocoapodsInstaller.install(versionSpec);
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
}
}
};
run();