File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -657,7 +657,7 @@ exports.createResolver = function (options) {
657
657
if ( typeof plugin === "function" ) {
658
658
/** @type {function(this: Resolver, Resolver): void } */
659
659
( plugin ) . call ( resolver , resolver ) ;
660
- } else {
660
+ } else if ( plugin ) {
661
661
plugin . apply ( resolver ) ;
662
662
}
663
663
}
Original file line number Diff line number Diff line change @@ -33,4 +33,44 @@ describe("plugins", function () {
33
33
}
34
34
) ;
35
35
} ) ;
36
+
37
+ it ( "should ignore 'false'/'null'/'undefined' plugins" , done => {
38
+ const FailedPlugin = class {
39
+ apply ( ) {
40
+ throw new Error ( "FailedPlugin" ) ;
41
+ }
42
+ } ;
43
+ const falsy = false ;
44
+ const resolver = ResolverFactory . createResolver ( {
45
+ fileSystem : require ( "fs" ) ,
46
+ plugins : [
47
+ false ,
48
+ null ,
49
+ undefined ,
50
+ falsy && new FailedPlugin ( ) ,
51
+ new CloneBasenamePlugin (
52
+ "after-existing-directory" ,
53
+ "undescribed-raw-file"
54
+ )
55
+ ]
56
+ } ) ;
57
+
58
+ resolver . resolve (
59
+ { } ,
60
+ __dirname ,
61
+ "./fixtures/directory-default" ,
62
+ { } ,
63
+ function ( err , result ) {
64
+ if ( err ) return done ( err ) ;
65
+ if ( ! result ) return done ( new Error ( "No result" ) ) ;
66
+ expect ( result ) . toEqual (
67
+ path . resolve (
68
+ __dirname ,
69
+ "fixtures/directory-default/directory-default.js"
70
+ )
71
+ ) ;
72
+ done ( ) ;
73
+ }
74
+ ) ;
75
+ } ) ;
36
76
} ) ;
You can’t perform that action at this time.
0 commit comments