-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputs.js
57 lines (46 loc) · 1.58 KB
/
inputs.js
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
const core = require('@actions/core');
const { inputs, defaults } = require('./constants.js');
function getSearchPath() {
const searchPath = core.getInput(inputs.SearchPath);
if (searchPath) {
return searchPath;
}
return defaults.SearchPath;
}
function getFileEncoding() {
const fileEncoding = core.getInput(inputs.FileEncoding);
if (fileEncoding) {
return fileEncoding;
}
return defaults.FileEncoding;
}
function getUploadOptions() {
const compressionLevelStr = core.getInput(inputs.CompressionLevel);
const retentionDaysStr = core.getInput(inputs.RetentionDays);
const overwriteStr = core.getInput(inputs.Overwrite);
const options = {};
if (compressionLevelStr) {
options.compressionLevel = parseInt(compressionLevelStr);
if (isNaN(options.compressionLevel)) {
core.setFailed(`Invalid ${inputs.CompressionLevel}. ${compressionLevelStr} is not a valid number.`);
}
if (options.compressionLevel < 0 || options.compressionLevel > 9) {
core.setFailed(`Invalid ${inputs.CompressionLevel}. Valid values are 0-9.`);
}
}
if (retentionDaysStr) {
options.retentionDays = parseInt(retentionDaysStr);
if (isNaN(options.retentionDays)) {
core.setFailed(`Invalid ${inputs.RetentionDays}. ${retentionDaysStr} is not a valid number.`);
}
}
if (overwriteStr) {
options.overwrite = ('true' == overwriteStr.toLowerCase())
}
return options;
}
module.exports = {
getSearchPath,
getFileEncoding,
getUploadOptions,
};