refactor: add deprecation log for addVendor

This commit is contained in:
Clark Du 2018-08-07 10:24:01 +01:00
parent ba7e6c735b
commit fe6c524be1
No known key found for this signature in database
GPG Key ID: 32CBD8CD478AF898
2 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import path from 'path'
import fs from 'fs'
import hash from 'hash-sum'
import consola from 'consola'
import { chainFn, sequence } from '../common/utils'
export default class ModuleContainer {
@ -21,8 +22,8 @@ export default class ModuleContainer {
await this.nuxt.callHook('modules:done', this)
}
addVendor(vendor) {
// Make it silent for backward compatibility with nuxt 1.x
addVendor() {
consola.warn('addVendor has been deprecated due to webpack4 optimization')
}
addTemplate(template) {

View File

@ -1,4 +1,5 @@
import { normalize } from 'path'
import consola from 'consola'
import { loadFixture, getPort, Nuxt, rp } from '../utils'
let port
@ -58,6 +59,15 @@ describe('module', () => {
expect(nuxt.__render_context).toBeTruthy()
})
test('AddVendor - deprecated', async () => {
jest.spyOn(consola, 'warn')
nuxt.moduleContainer.addVendor('nuxt-test')
expect(consola.warn).toHaveBeenCalledWith('addVendor has been deprecated due to webpack4 optimization')
consola.warn.mockRestore()
})
// Close server and ask nuxt to stop listening to file changes
afterAll(async () => {
await nuxt.close()