UNPKG

@atomist/sdm

Version:

Atomist Software Delivery Machine SDK

63 lines 2.65 kB
"use strict"; /* * Copyright © 2020 Atomist, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.isSkillConfigured = void 0; const commit_1 = require("../../../api-helper/pushtest/commit"); const PushTest_1 = require("../../../api/mapping/PushTest"); const commonPushTests_1 = require("../../../api/mapping/support/commonPushTests"); const DefaultSkillConfigurationKeys = { hasCommit: "hasCommit", hasFile: "hasFile", isBranch: "isBranch", isDefaultBranch: "isDefaultBranch", }; /** * Push test that tests against some well-known pushTests based on skill * configuration */ function isSkillConfigured(keys) { const keysToUse = Object.assign(Object.assign({}, DefaultSkillConfigurationKeys), keys); return PushTest_1.pushTest("is skill configured", async (pli) => { var _a, _b; const skillConfiguration = ((_b = (_a = pli.skill) === null || _a === void 0 ? void 0 : _a.configuration) === null || _b === void 0 ? void 0 : _b.parameters) || {}; if (!!skillConfiguration[keysToUse.hasFile]) { if (!(await commonPushTests_1.hasFile(skillConfiguration[keysToUse.hasFile]).mapping(pli))) { return false; } } if (!!skillConfiguration[keysToUse.isBranch]) { const branchRegExp = new RegExp(skillConfiguration[keysToUse.isBranch]); if (!(await commonPushTests_1.isBranch(branchRegExp).mapping(pli))) { return false; } } if (!!skillConfiguration[keysToUse.isDefaultBranch]) { if (!(await commonPushTests_1.ToDefaultBranch.mapping(pli))) { return false; } } if (!!skillConfiguration[keysToUse.hasCommit]) { const commitRegExp = new RegExp(skillConfiguration[keysToUse.hasCommit]); if (!(await commit_1.hasCommit(commitRegExp).mapping(pli))) { return false; } } return true; }); } exports.isSkillConfigured = isSkillConfigured; //# sourceMappingURL=isSkillConfigured.js.map