source: frontend/node_modules/fork-ts-checker-webpack-plugin/lib/hooks/tapDoneToAsyncGetIssues.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 4.1 KB
Line 
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4 return new (P || (P = Promise))(function (resolve, reject) {
5 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8 step((generator = generator.apply(thisArg, _arguments || [])).next());
9 });
10};
11var __importDefault = (this && this.__importDefault) || function (mod) {
12 return (mod && mod.__esModule) ? mod : { "default": mod };
13};
14Object.defineProperty(exports, "__esModule", { value: true });
15const chalk_1 = __importDefault(require("chalk"));
16const pluginHooks_1 = require("./pluginHooks");
17const WebpackFormatter_1 = require("../formatter/WebpackFormatter");
18const IssueWebpackError_1 = require("../issue/IssueWebpackError");
19const isPending_1 = __importDefault(require("../utils/async/isPending"));
20const wait_1 = __importDefault(require("../utils/async/wait"));
21function tapDoneToAsyncGetIssues(compiler, configuration, state) {
22 const hooks = pluginHooks_1.getForkTsCheckerWebpackPluginHooks(compiler);
23 compiler.hooks.done.tap('ForkTsCheckerWebpackPlugin', (stats) => __awaiter(this, void 0, void 0, function* () {
24 if (stats.compilation.compiler !== compiler) {
25 // run only for the compiler that the plugin was registered for
26 return;
27 }
28 const reportPromise = state.issuesReportPromise;
29 const issuesPromise = state.issuesPromise;
30 let issues;
31 try {
32 if (yield isPending_1.default(issuesPromise)) {
33 hooks.waiting.call(stats.compilation);
34 configuration.logger.issues.log(chalk_1.default.cyan('Issues checking in progress...'));
35 }
36 else {
37 // wait 10ms to log issues after webpack stats
38 yield wait_1.default(10);
39 }
40 issues = yield issuesPromise;
41 }
42 catch (error) {
43 hooks.error.call(error, stats.compilation);
44 return;
45 }
46 if (!issues) {
47 // some error has been thrown or it was canceled
48 return;
49 }
50 if (reportPromise !== state.issuesReportPromise) {
51 // there is a newer report - ignore this one
52 return;
53 }
54 // filter list of issues by provided issue predicate
55 issues = issues.filter(configuration.issue.predicate);
56 // modify list of issues in the plugin hooks
57 issues = hooks.issues.call(issues, stats.compilation);
58 const formatter = WebpackFormatter_1.createWebpackFormatter(configuration.formatter);
59 if (issues.length) {
60 // follow webpack's approach - one process.write to stderr with all errors and warnings
61 configuration.logger.issues.error(issues.map((issue) => formatter(issue)).join('\n'));
62 }
63 else {
64 configuration.logger.issues.log(chalk_1.default.green('No issues found.'));
65 }
66 // report issues to webpack-dev-server, if it's listening
67 // skip reporting if there are no issues, to avoid an extra hot reload
68 if (issues.length && state.webpackDevServerDoneTap) {
69 issues.forEach((issue) => {
70 const error = new IssueWebpackError_1.IssueWebpackError(configuration.formatter(issue), issue);
71 if (issue.severity === 'warning') {
72 stats.compilation.warnings.push(error);
73 }
74 else {
75 stats.compilation.errors.push(error);
76 }
77 });
78 state.webpackDevServerDoneTap.fn(stats);
79 }
80 if (stats.startTime) {
81 configuration.logger.infrastructure.info(`Time: ${Math.round(Date.now() - stats.startTime).toString()} ms`);
82 }
83 }));
84}
85exports.tapDoneToAsyncGetIssues = tapDoneToAsyncGetIssues;
Note: See TracBrowser for help on using the repository browser.