Skip to content

Commit

Permalink
feat($core): assert return type for functional plugin (#1516)
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma authored and ulivz committed Apr 6, 2019
1 parent 5c307c9 commit 74887c5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/@vuepress/core/lib/node/plugin-api/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ exports.flattenPlugin = function (
// 'Object.create' here is to give each plugin a separate context,
// but also own the inheritance context.
config = config(pluginOptions, Object.create(pluginContext), self)
const { valid, warnMsg } = assertTypes(config, [Object])
if (!valid) {
logger.warn(
`[${chalk.gray(shortcut)}] `
+ `Invalid value for plugin: ${warnMsg}`
)
config = {}
}
}

// respect name in local plugin config
Expand Down

0 comments on commit 74887c5

Please sign in to comment.