Skip to content

Commit db6d3d4

Browse files
motiapi0
authored andcommitted
fix(module): warn if default strategy is not valid (#365)
1 parent c02ca45 commit db6d3d4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/module/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ module.exports = function (moduleOptions) {
2424
delete options.strategies
2525

2626
// Set defaultStrategy
27-
if (!options.defaultStrategy && strategies.length) {
28-
options.defaultStrategy = strategies[0]._name
29-
} else {
27+
const strategyNames = strategies.map(x => x._name)
28+
options.defaultStrategy = options.defaultStrategy || strategyNames[0]
29+
30+
if (!options.defaultStrategy) {
3031
logger.warn('no strategy defined!')
32+
} else if(strategyNames.indexOf(options.defaultStrategy) === -1) {
33+
logger.warn(`strategy ${options.defaultStrategy} is not defined!`)
3134
}
3235

3336
// Copy plugin

0 commit comments

Comments
 (0)