Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
fix(requires): require array doesn't have options
Browse files Browse the repository at this point in the history
allows to add objects or string in the require array in configuration object
  • Loading branch information
MatteoGabriele committed Nov 22, 2017
1 parent c4918fb commit b82dc47
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/collectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@ export const setters = function () {

export const requires = function () {
config.require.forEach(value => {
if (typeof value !== 'string') {
if (typeof value !== 'string' && typeof value !== 'object') {
throw new Error(
'[vue-analytics] Wrong configuration in the plugin options. \n' +
'The "require" array requires each item to be a string.'
'The "require" array requires each item to be a string or to have a "name" and an "options" property.'
)
}

_require(value)
const pluginName = value.name || value

if (value.options) {
_require(pluginName, value.options)
return
}

_require(pluginName)
})
}

Expand Down

0 comments on commit b82dc47

Please sign in to comment.