MCPcopy
hub / github.com/webpack/webpack / defaultHandler

Function defaultHandler

lib/ProgressPlugin.js:161–187  ·  view source on GitHub ↗
(percentage, msg, ...args)

Source from the content-addressed store, hash-verified

159
160 /** @type {HandlerFn} */
161 const defaultHandler = (percentage, msg, ...args) => {
162 if (profile) {
163 reportProfile(logger, lastStateInfo, percentage, msg, args);
164 }
165
166 if (progressBar) {
167 const reportBar = createReportBar(progressBar.name, progressBar.color);
168 const c = getColors();
169 /** @type {string} */
170 const currentBar = reportBar(percentage);
171
172 if (percentage === 1) {
173 logger.status();
174 } else if (msg) {
175 logger.status(
176 `${currentBar} (${Math.floor(percentage * 100)}%)`,
177 `\n${[msg, ...args].map(c.gray).join(" ")}`
178 );
179 } else {
180 logger.status(`${currentBar} (${Math.floor(percentage * 100)}%)`);
181 }
182 return;
183 }
184
185 logger.status(`${Math.floor(percentage * 100)}%`, msg, ...args);
186 if (percentage === 1 || (!msg && args.length === 0)) logger.status();
187 };
188
189 return defaultHandler;
190};

Callers

nothing calls this directly

Calls 3

reportProfileFunction · 0.85
createReportBarFunction · 0.85
statusMethod · 0.65

Tested by

no test coverage detected