johnagan / clean-webpack-plugin

Compare 021d2b6 ... +3 ... 0edf40f

Coverage Reach
clean-webpack-plugin.ts

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 1 of 4 files from the diff.

@@ -1,8 +1,6 @@
Loading
1 -
import path from 'path';
2 1
import { sync as delSync } from 'del';
3 -
import { Compiler, Stats, compilation as compilationType } from 'webpack';
4 -
5 -
type Compilation = compilationType.Compilation;
2 +
import path from 'path';
3 +
import { AssetInfo, Compilation, Compiler, Stats } from 'webpack';
6 4
7 5
export interface Options {
8 6
    /**
@@ -180,36 +178,19 @@
Loading
180 178
         * webpack 4+ comes with a new plugin system.
181 179
         *
182 180
         * Check for hooks in-order to support old plugin system
181 +
         * webpack 5+ removed the old system, the check now breaks
183 182
         */
184 183
        const hooks = compiler.hooks;
185 184
186 185
        if (this.cleanOnceBeforeBuildPatterns.length !== 0) {
187 -
            if (hooks) {
188 -
                hooks.emit.tap('clean-webpack-plugin', (compilation) => {
189 -
                    this.handleInitial(compilation);
190 -
                });
191 -
            } else {
192 -
                compiler.plugin('emit', (compilation, callback) => {
193 -
                    try {
194 -
                        this.handleInitial(compilation);
195 -
196 -
                        callback();
197 -
                    } catch (error) {
198 -
                        callback(error);
199 -
                    }
200 -
                });
201 -
            }
202 -
        }
203 -
204 -
        if (hooks) {
205 -
            hooks.done.tap('clean-webpack-plugin', (stats) => {
206 -
                this.handleDone(stats);
207 -
            });
208 -
        } else {
209 -
            compiler.plugin('done', (stats) => {
210 -
                this.handleDone(stats);
186 +
            hooks.emit.tap('clean-webpack-plugin', (compilation) => {
187 +
                this.handleInitial(compilation);
211 188
            });
212 189
        }
190 +
191 +
        hooks.done.tap('clean-webpack-plugin', (stats) => {
192 +
            this.handleDone(stats);
193 +
        });
213 194
    }
214 195
215 196
    /**
@@ -257,14 +238,22 @@
Loading
257 238
        /**
258 239
         * Fetch Webpack's output asset files
259 240
         */
260 -
        const assets =
261 -
            stats.toJson(
262 -
                {
263 -
                    assets: true,
264 -
                },
265 -
                true,
266 -
            ).assets || [];
267 -
        const assetList = assets.map((asset: { name: string }) => {
241 +
        const assets: AssetInfo[] =
242 +
            stats.toJson({
243 +
                assets: true,
244 +
            }).assets || [];
245 +
246 +
        const relatedAssets = assets
247 +
            .map((p) => {
248 +
                return ((p.related && Array.isArray(p.related) && p.related) ||
249 +
                    []) as AssetInfo[];
250 +
            })
251 +
            .reduce((prev, cur) => {
252 +
                return [...prev, ...cur];
253 +
            }, []);
254 +
255 +
        const allAssets = [...assets, ...relatedAssets];
256 +
        const assetList = allAssets.map((asset) => {
268 257
            return asset.name;
269 258
        });
270 259

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
src/clean-webpack-plugin.ts -0.07% 98.80%
Project Totals (1 files) 98.80%
Loading