Improve string split

This commit is contained in:
Dave Hadka 2020-06-02 10:21:03 -05:00
parent e561127c3e
commit d60d2bef10
8 changed files with 95 additions and 27 deletions

22
dist/restore/index.js vendored
View file

@ -5306,7 +5306,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = void 0;
exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.getCacheState = exports.setOutputAndState = exports.setCacheHitOutput = exports.setCacheState = exports.isExactKeyMatch = void 0;
const core = __importStar(__webpack_require__(470));
const constants_1 = __webpack_require__(694);
function isExactKeyMatch(key, cacheKey) {
@ -5350,6 +5350,14 @@ function isValidEvent() {
return constants_1.RefKey in process.env && Boolean(process.env[constants_1.RefKey]);
}
exports.isValidEvent = isValidEvent;
function getInputAsArray(name, options) {
return core
.getInput(name, options)
.split("\n")
.map(s => s.trim())
.filter(x => x !== "");
}
exports.getInputAsArray = getInputAsArray;
/***/ }),
@ -6835,14 +6843,10 @@ function run() {
}
const primaryKey = core.getInput(constants_1.Inputs.Key, { required: true });
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
const restoreKeys = core
.getInput(constants_1.Inputs.RestoreKeys)
.split("\n")
.filter(x => x !== "");
const cachePaths = core
.getInput(constants_1.Inputs.Path, { required: true })
.split("\n")
.filter(x => x !== "");
const restoreKeys = utils.getInputAsArray(constants_1.Inputs.RestoreKeys);
const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
required: true
});
try {
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys);
if (!cacheKey) {