UNPKG

@ts-common/azure-js-dev-tools

Version:

Developer dependencies for TypeScript related projects

108 lines 5.05 kB
"use strict"; /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for * license information. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.checkEverything = void 0; var tslib_1 = require("tslib"); var checkForOnlyCalls_1 = require("./checkForOnlyCalls"); var checkForSkipCalls_1 = require("./checkForSkipCalls"); var checkPackageJsonVersion_1 = require("./checkPackageJsonVersion"); var logger_1 = require("./logger"); var checkForUnstagedChanges_1 = require("./checkForUnstagedChanges"); /** * Run all of the repository checks. * @returns The number of repository checks that failed. */ function checkEverything(options) { if (options === void 0) { options = {}; } return tslib_1.__awaiter(this, void 0, void 0, function () { var logger, exitCode, runCheck, checks, checks_1, checks_1_1, check, e_1_1; var e_1, _a; var _this = this; return tslib_1.__generator(this, function (_b) { switch (_b.label) { case 0: logger = options.logger || logger_1.getDefaultLogger(); exitCode = 0; runCheck = function (checkName, check) { return tslib_1.__awaiter(_this, void 0, void 0, function () { var _a; return tslib_1.__generator(this, function (_b) { switch (_b.label) { case 0: logger.logSection("Checking " + checkName + "..."); _a = 0; return [4 /*yield*/, Promise.resolve(check())]; case 1: if (_a !== (_b.sent())) { ++exitCode; } return [2 /*return*/]; } }); }); }; checks = []; if (options.checkPackageJsonVersionOptions !== false) { checks.push(checkPackageJsonVersion_1.checkPackageJsonVersion(options.checkPackageJsonVersionOptions)); } if (options.checkForOnlyCallsOptions !== false) { checks.push(checkForOnlyCalls_1.checkForOnlyCalls(options.checkForOnlyCallsOptions)); } if (options.checkForSkipCallsOptions !== false) { checks.push(checkForSkipCalls_1.checkForSkipCalls(options.checkForSkipCallsOptions)); } if (options.checkForUnstagedChangesOptions !== false) { checks.push(checkForUnstagedChanges_1.checkForUnstagedChanges(options.checkForUnstagedChangesOptions)); } if (options.additionalChecks) { if (Array.isArray(options.additionalChecks)) { checks.push.apply(checks, tslib_1.__spread(options.additionalChecks)); } else { checks.push(options.additionalChecks); } } _b.label = 1; case 1: _b.trys.push([1, 6, 7, 8]); checks_1 = tslib_1.__values(checks), checks_1_1 = checks_1.next(); _b.label = 2; case 2: if (!!checks_1_1.done) return [3 /*break*/, 5]; check = checks_1_1.value; if (!check) return [3 /*break*/, 4]; return [4 /*yield*/, runCheck(check.name, check.check)]; case 3: _b.sent(); _b.label = 4; case 4: checks_1_1 = checks_1.next(); return [3 /*break*/, 2]; case 5: return [3 /*break*/, 8]; case 6: e_1_1 = _b.sent(); e_1 = { error: e_1_1 }; return [3 /*break*/, 8]; case 7: try { if (checks_1_1 && !checks_1_1.done && (_a = checks_1.return)) _a.call(checks_1); } finally { if (e_1) throw e_1.error; } return [7 /*endfinally*/]; case 8: if (exitCode === 0) { logger.logInfo(exitCode + " checks failed."); } else { logger.logError(exitCode + " checks failed."); } process.exitCode = exitCode; return [2 /*return*/, exitCode]; } }); }); } exports.checkEverything = checkEverything; //# sourceMappingURL=checkEverything.js.map