johnagan / clean-webpack-plugin
Showing 1 of 2 files from the diff.

@@ -1,6 +1,8 @@
Loading
1 1
import path from 'path';
2 2
import { sync as delSync } from 'del';
3 -
import { Compiler, Stats } from 'webpack';
3 +
import { Compiler, Stats, compilation as compilationType } from 'webpack';
4 +
5 +
type Compilation = compilationType.Compilation;
4 6
5 7
export interface Options {
6 8
    /**
@@ -183,12 +185,18 @@
Loading
183 185
184 186
        if (this.cleanOnceBeforeBuildPatterns.length !== 0) {
185 187
            if (hooks) {
186 -
                hooks.compile.tap('clean-webpack-plugin', () => {
187 -
                    this.handleInitial();
188 +
                hooks.emit.tap('clean-webpack-plugin', (compilation) => {
189 +
                    this.handleInitial(compilation);
188 190
                });
189 191
            } else {
190 -
                compiler.plugin('compile', () => {
191 -
                    this.handleInitial();
192 +
                compiler.plugin('emit', (compilation, callback) => {
193 +
                    try {
194 +
                        this.handleInitial(compilation);
195 +
196 +
                        callback();
197 +
                    } catch (error) {
198 +
                        callback(error);
199 +
                    }
192 200
                });
193 201
            }
194 202
        }
@@ -211,11 +219,21 @@
Loading
211 219
     *
212 220
     * Warning: It is recommended to initially clean your build directory outside of webpack to minimize unexpected behavior.
213 221
     */
214 -
    handleInitial() {
222 +
    handleInitial(compilation: Compilation) {
215 223
        if (this.initialClean) {
216 224
            return;
217 225
        }
218 226
227 +
        /**
228 +
         * Do not remove files if there are compilation errors
229 +
         *
230 +
         * Handle logging inside this.handleDone
231 +
         */
232 +
        const stats = compilation.getStats();
233 +
        if (stats.hasErrors()) {
234 +
            return;
235 +
        }
236 +
219 237
        this.initialClean = true;
220 238
221 239
        this.removeFiles(this.cleanOnceBeforeBuildPatterns);
Files Coverage
src/clean-webpack-plugin.ts 98.86%
Project Totals (1 files) 98.86%
uin6xm35hwceh2wh
uin6xm35hwceh2wh
uin6xm35hwceh2wh
ehpil9x2xjtmfbgj
shycuuotyp78l7ow
shycuuotyp78l7ow
shycuuotyp78l7ow
9m5r8i3b74sp6f8k
9m5r8i3b74sp6f8k
9m5r8i3b74sp6f8k
g9uhluc95fj4ybix
g9uhluc95fj4ybix
dqmr0gbg0o9rve88
g9uhluc95fj4ybix
dqmr0gbg0o9rve88
dqmr0gbg0o9rve88
ehpil9x2xjtmfbgj
ehpil9x2xjtmfbgj

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading