source: imaps-frontend/node_modules/webpack/lib/Stats.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8/** @typedef {import("../declarations/WebpackOptions").StatsOptions} StatsOptions */
9/** @typedef {import("./Compilation")} Compilation */
10/** @typedef {import("./Compilation").NormalizedStatsOptions} NormalizedStatsOptions */
11/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsCompilation} StatsCompilation */
12
13class Stats {
14 /**
15 * @param {Compilation} compilation webpack compilation
16 */
17 constructor(compilation) {
18 this.compilation = compilation;
19 }
20
21 get hash() {
22 return this.compilation.hash;
23 }
24
25 get startTime() {
26 return this.compilation.startTime;
27 }
28
29 get endTime() {
30 return this.compilation.endTime;
31 }
32
33 /**
34 * @returns {boolean} true if the compilation had a warning
35 */
36 hasWarnings() {
37 return (
38 this.compilation.getWarnings().length > 0 ||
39 this.compilation.children.some(child => child.getStats().hasWarnings())
40 );
41 }
42
43 /**
44 * @returns {boolean} true if the compilation encountered an error
45 */
46 hasErrors() {
47 return (
48 this.compilation.errors.length > 0 ||
49 this.compilation.children.some(child => child.getStats().hasErrors())
50 );
51 }
52
53 /**
54 * @param {(string | boolean | StatsOptions)=} options stats options
55 * @returns {StatsCompilation} json output
56 */
57 toJson(options) {
58 const normalizedOptions = this.compilation.createStatsOptions(options, {
59 forToString: false
60 });
61
62 const statsFactory = this.compilation.createStatsFactory(normalizedOptions);
63
64 return statsFactory.create("compilation", this.compilation, {
65 compilation: this.compilation
66 });
67 }
68
69 /**
70 * @param {(string | boolean | StatsOptions)=} options stats options
71 * @returns {string} string output
72 */
73 toString(options) {
74 const normalizedOptions = this.compilation.createStatsOptions(options, {
75 forToString: true
76 });
77
78 const statsFactory = this.compilation.createStatsFactory(normalizedOptions);
79 const statsPrinter = this.compilation.createStatsPrinter(normalizedOptions);
80
81 const data = statsFactory.create("compilation", this.compilation, {
82 compilation: this.compilation
83 });
84 const result = statsPrinter.print("compilation", data);
85 return result === undefined ? "" : result;
86 }
87}
88
89module.exports = Stats;
Note: See TracBrowser for help on using the repository browser.