-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinputs.ts
More file actions
67 lines (60 loc) · 2.27 KB
/
Copy pathinputs.ts
File metadata and controls
67 lines (60 loc) · 2.27 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
import * as core from "@actions/core";
import * as Shellwords from "shellwords-ts";
import { envsubst } from "./envsubst.js"
import { type OnDirtyFiles, parseOnDirtyFiles } from "./dirty-files.js"
export type Inputs = {
workingDirectory: string | null;
test: boolean;
color: boolean;
stackArguments: string[];
stackSetupArguments: string[];
stackQueryArguments: string[];
stackBuildArgumentsDependencies: string[];
stackBuildArgumentsBuild: string[];
stackBuildArgumentsTest: string[];
cachePrefix: string;
cacheSaveAlways: boolean;
onDirtyFiles: OnDirtyFiles;
installStack: boolean;
upgradeStack: boolean;
compilerTools: string[];
// Deprecated
stackYaml: string | null;
};
export function getInputs(): Inputs {
const getBuildArguments = (step: string): string[] => {
return getShellWordsInput("stack-build-arguments").concat(
getShellWordsInput(`stack-build-arguments-${step}`),
);
};
const rawOnDirtyFiles = core.getInput("on-dirty-files", { required: true });
return {
workingDirectory: getInputDefault("working-directory", null),
test: core.getBooleanInput("test"),
color: core.getBooleanInput("color"),
stackArguments: getShellWordsInput("stack-arguments"),
stackSetupArguments: getShellWordsInput("stack-setup-arguments"),
stackQueryArguments: getShellWordsInput("stack-query-arguments"),
stackBuildArgumentsDependencies: getBuildArguments("dependencies"),
stackBuildArgumentsBuild: getBuildArguments("build"),
stackBuildArgumentsTest: getBuildArguments("test"),
cachePrefix: core.getInput("cache-prefix"),
cacheSaveAlways: core.getBooleanInput("cache-save-always"),
onDirtyFiles: parseOnDirtyFiles(rawOnDirtyFiles),
installStack: core.getBooleanInput("install-stack"),
upgradeStack: core.getBooleanInput("upgrade-stack"),
compilerTools: core.getMultilineInput("compiler-tools"),
stackYaml: getInputDefault("stack-yaml", null),
};
}
function getInputDefault<T>(name: string, d: T): string | T {
const raw = core.getInput(name, { trimWhitespace: true });
return raw === "" ? d : raw;
}
function getShellWordsInput(
name: string,
options?: core.InputOptions,
): string[] {
const raw = core.getMultilineInput(name, options).join(" ");
return Shellwords.split(raw).map(envsubst);
}