UNPKG

typescript-assistant

Version:

Combines and integrates professional Typescript tools into your project

38 lines 2.11 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createPrePushCommand = createPrePushCommand; function createPrePushCommand(deps) { const { compiler, nyc, git, logger } = deps; return { execute() { return __awaiter(this, arguments, void 0, function* (options = {}) { const { disabledProjects, testConfig, testsGlob } = options; let timestamp = new Date().getTime(); let pristine = yield git.isPristine(); if (!pristine) { logger.error("pre-push", "The working directory contains changes that are not committed."); logger.error("pre-push", "The pre-push checks can therefore not be run"); logger.error("pre-push", "Please stash you work before pushing"); return false; } let results = yield Promise.all([ compiler.runOnce([], disabledProjects, { compileLimit: 1 }), nyc.run(true, testConfig, testsGlob), ]); let toolErrors = results.filter((result) => result === false).length; logger.log("pre-push", `Pre-push tasks took ${Math.round((new Date().getTime() - timestamp) / 1000)} seconds`); return toolErrors === 0; }); }, }; } //# sourceMappingURL=pre-push.js.map