1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | class Stats {
|
13 | |
14 |
|
15 |
|
16 | constructor(compilation) {
|
17 | this.compilation = compilation;
|
18 | }
|
19 |
|
20 | get hash() {
|
21 | return this.compilation.hash;
|
22 | }
|
23 |
|
24 | get startTime() {
|
25 | return this.compilation.startTime;
|
26 | }
|
27 |
|
28 | get endTime() {
|
29 | return this.compilation.endTime;
|
30 | }
|
31 |
|
32 | |
33 |
|
34 |
|
35 | hasWarnings() {
|
36 | return (
|
37 | this.compilation.warnings.length > 0 ||
|
38 | this.compilation.children.some(child => child.getStats().hasWarnings())
|
39 | );
|
40 | }
|
41 |
|
42 | |
43 |
|
44 |
|
45 | hasErrors() {
|
46 | return (
|
47 | this.compilation.errors.length > 0 ||
|
48 | this.compilation.children.some(child => child.getStats().hasErrors())
|
49 | );
|
50 | }
|
51 |
|
52 | |
53 |
|
54 |
|
55 |
|
56 | toJson(options) {
|
57 | options = this.compilation.createStatsOptions(options, {
|
58 | forToString: false
|
59 | });
|
60 |
|
61 | const statsFactory = this.compilation.createStatsFactory(options);
|
62 |
|
63 | return statsFactory.create("compilation", this.compilation, {
|
64 | compilation: this.compilation
|
65 | });
|
66 | }
|
67 |
|
68 | toString(options) {
|
69 | options = this.compilation.createStatsOptions(options, {
|
70 | forToString: true
|
71 | });
|
72 |
|
73 | const statsFactory = this.compilation.createStatsFactory(options);
|
74 | const statsPrinter = this.compilation.createStatsPrinter(options);
|
75 |
|
76 | const data = statsFactory.create("compilation", this.compilation, {
|
77 | compilation: this.compilation
|
78 | });
|
79 | const result = statsPrinter.print("compilation", data);
|
80 | return result === undefined ? "" : result;
|
81 | }
|
82 | }
|
83 |
|
84 | module.exports = Stats;
|