source: trip-planner-front/node_modules/webpack/lib/Stats.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.0 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("./stats/DefaultStatsFactoryPlugin").StatsCompilation} StatsCompilation */
11
12class Stats {
13 /**
14 * @param {Compilation} compilation webpack compilation
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 * @returns {boolean} true if the compilation had a warning
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 * @returns {boolean} true if the compilation encountered an error
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 * @param {(string|StatsOptions)=} options stats options
54 * @returns {StatsCompilation} json output
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
84module.exports = Stats;
Note: See TracBrowser for help on using the repository browser.