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