This commit is contained in:
Pooya Parsa 2017-05-31 18:56:49 +04:30
parent c5ca8c64f1
commit 79b97093d0

View File

@ -9,14 +9,14 @@ import {chainFn, sequence} from './utils'
const debug = require('debug')('nuxt:module')
class Module {
constructor(nuxt) {
constructor (nuxt) {
this.nuxt = nuxt
this.options = nuxt.options
this.modules = []
this.initialized = false
}
async init() {
async init () {
if (this.initialized) {
debug('[nuxt] Modules are already initialized')
return
@ -27,7 +27,7 @@ class Module {
this.initialized = true
}
addVendor(vendor) {
addVendor (vendor) {
/* istanbul ignore if */
if (!vendor) {
return
@ -35,7 +35,7 @@ class Module {
this.options.build.vendor = uniq(this.options.build.vendor.concat(vendor))
}
addTemplate(template) {
addTemplate (template) {
/* istanbul ignore if */
if (!template) {
return
@ -61,7 +61,7 @@ class Module {
return templateObj
}
addPlugin(template) {
addPlugin (template) {
const {dst} = this.addTemplate(template)
// Add to nuxt plugins
this.options.plugins.push({
@ -70,19 +70,19 @@ class Module {
})
}
addServerMiddleware(middleware) {
addServerMiddleware (middleware) {
this.options.serverMiddleware.push(middleware)
}
extendBuild(fn) {
extendBuild (fn) {
this.options.build.extend = chainFn(this.options.build.extend, fn)
}
extendRoutes(fn) {
extendRoutes (fn) {
this.options.router.extendRoutes = chainFn(this.options.router.extendRoutes, fn)
}
requireModule(moduleOpts) {
requireModule (moduleOpts) {
if (this.modules.indexOf(moduleOpts) !== -1 || this.modules.indexOf(moduleOpts.src) !== -1) {
return false
}
@ -90,7 +90,7 @@ class Module {
return this.addModule(moduleOpts)
}
addModule(moduleOpts) {
addModule (moduleOpts) {
/* istanbul ignore if */
if (!moduleOpts) {
return