mirror of https://github.com/nuxt/nuxt.git
coverage
This commit is contained in:
parent
e0ea1dd1ee
commit
a594606f85
|
@ -45,10 +45,12 @@ export default class Builder extends Tapable {
|
||||||
|
|
||||||
async build () {
|
async build () {
|
||||||
// Avoid calling build() method multiple times when dev:true
|
// Avoid calling build() method multiple times when dev:true
|
||||||
|
/* istanbul ignore if */
|
||||||
if (this._buildStatus === STATUS.BUILD_DONE && this.options.dev) {
|
if (this._buildStatus === STATUS.BUILD_DONE && this.options.dev) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
// If building
|
// If building
|
||||||
|
/* istanbul ignore if */
|
||||||
if (this._buildStatus === STATUS.BUILDING) {
|
if (this._buildStatus === STATUS.BUILDING) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -287,6 +289,7 @@ export default class Builder extends Tapable {
|
||||||
// Run after each compile
|
// Run after each compile
|
||||||
this.compiler.plugin('done', stats => {
|
this.compiler.plugin('done', stats => {
|
||||||
// Don't reload failed builds
|
// Don't reload failed builds
|
||||||
|
/* istanbul ignore if */
|
||||||
if (stats.hasErrors() || stats.hasWarnings()) {
|
if (stats.hasErrors() || stats.hasWarnings()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -311,6 +314,7 @@ export default class Builder extends Tapable {
|
||||||
} else {
|
} else {
|
||||||
// Build and watch for changes
|
// Build and watch for changes
|
||||||
compiler.watch(this.options.watchers.webpack, (err) => {
|
compiler.watch(this.options.watchers.webpack, (err) => {
|
||||||
|
/* istanbul ignore if */
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject(err)
|
return reject(err)
|
||||||
}
|
}
|
||||||
|
@ -326,6 +330,7 @@ export default class Builder extends Tapable {
|
||||||
if (err) return console.error(err) // eslint-disable-line no-console
|
if (err) return console.error(err) // eslint-disable-line no-console
|
||||||
// Show build stats for production
|
// Show build stats for production
|
||||||
console.log(stats.toString(this.webpackStats)) // eslint-disable-line no-console
|
console.log(stats.toString(this.webpackStats)) // eslint-disable-line no-console
|
||||||
|
/* istanbul ignore if */
|
||||||
if (stats.hasErrors()) {
|
if (stats.hasErrors()) {
|
||||||
return reject(new Error('Webpack build exited with errors'))
|
return reject(new Error('Webpack build exited with errors'))
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ export default class Generator extends Tapable {
|
||||||
debug('Destination folder cleaned')
|
debug('Destination folder cleaned')
|
||||||
|
|
||||||
// Copy static and built files
|
// Copy static and built files
|
||||||
|
/* istanbul ignore if */
|
||||||
if (fs.existsSync(srcStaticPath)) {
|
if (fs.existsSync(srcStaticPath)) {
|
||||||
await copy(srcStaticPath, distPath)
|
await copy(srcStaticPath, distPath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { styleLoader, extractStyles } from './helpers'
|
||||||
export default function webpackBaseConfig ({ isClient, isServer }) {
|
export default function webpackBaseConfig ({ isClient, isServer }) {
|
||||||
const nodeModulesDir = join(__dirname, '..', 'node_modules')
|
const nodeModulesDir = join(__dirname, '..', 'node_modules')
|
||||||
|
|
||||||
|
/* istanbul ignore if */
|
||||||
if (!Array.isArray(this.options.build.postcss)) {
|
if (!Array.isArray(this.options.build.postcss)) {
|
||||||
this.options.build.postcss = [
|
this.options.build.postcss = [
|
||||||
autoprefixer({
|
autoprefixer({
|
||||||
|
|
|
@ -57,6 +57,7 @@ export default function webpackClientConfig () {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Webpack common plugins
|
// Webpack common plugins
|
||||||
|
/* istanbul ignore if */
|
||||||
if (!Array.isArray(config.plugins)) {
|
if (!Array.isArray(config.plugins)) {
|
||||||
config.plugins = []
|
config.plugins = []
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,7 @@ export function r () {
|
||||||
export function flatRoutes (router, path = '', routes = []) {
|
export function flatRoutes (router, path = '', routes = []) {
|
||||||
router.forEach((r) => {
|
router.forEach((r) => {
|
||||||
if (!r.path.includes(':') && !r.path.includes('*')) {
|
if (!r.path.includes(':') && !r.path.includes('*')) {
|
||||||
|
/* istanbul ignore if */
|
||||||
if (r.children) {
|
if (r.children) {
|
||||||
flatRoutes(r.children, path + r.path + '/', routes)
|
flatRoutes(r.children, path + r.path + '/', routes)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -38,6 +38,7 @@ export default class ModuleContainer extends Tapable {
|
||||||
const srcPath = path.parse(src)
|
const srcPath = path.parse(src)
|
||||||
/* istanbul ignore if */
|
/* istanbul ignore if */
|
||||||
if (!src || typeof src !== 'string' || !fs.existsSync(src)) {
|
if (!src || typeof src !== 'string' || !fs.existsSync(src)) {
|
||||||
|
/* istanbul ignore next */
|
||||||
debug('[nuxt] invalid template', template)
|
debug('[nuxt] invalid template', template)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ export default class Nuxt extends Tapable {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
errorHandler () {
|
errorHandler /* istanbul ignore next */ () {
|
||||||
// Silent
|
// Silent
|
||||||
if (this.options.errorHandler === false) {
|
if (this.options.errorHandler === false) {
|
||||||
return
|
return
|
||||||
|
|
|
@ -36,6 +36,7 @@ export default function Options (_options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore publicPath on dev
|
// Ignore publicPath on dev
|
||||||
|
/* istanbul ignore if */
|
||||||
if (options.dev && isUrl(options.build.publicPath)) {
|
if (options.dev && isUrl(options.build.publicPath)) {
|
||||||
options.build.publicPath = defaultOptions.build.publicPath
|
options.build.publicPath = defaultOptions.build.publicPath
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
import ansiHTML from 'ansi-html'
|
import ansiHTML from "ansi-html";
|
||||||
import serialize from 'serialize-javascript'
|
import serialize from "serialize-javascript";
|
||||||
import generateETag from 'etag'
|
import generateETag from "etag";
|
||||||
import fresh from 'fresh'
|
import fresh from "fresh";
|
||||||
import Tapable from 'tappable'
|
import Tapable from "tappable";
|
||||||
import pify from 'pify'
|
import pify from "pify";
|
||||||
import serveStatic from 'serve-static'
|
import compression from "compression";
|
||||||
import compression from 'compression'
|
import _ from "lodash";
|
||||||
import _ from 'lodash'
|
import { join, resolve } from "path";
|
||||||
import { resolve, join } from 'path'
|
import fs from "fs-extra";
|
||||||
import fs from 'fs-extra'
|
import { createBundleRenderer } from "vue-server-renderer";
|
||||||
import { createBundleRenderer } from 'vue-server-renderer'
|
import { encodeHtml, getContext, setAnsiColors } from "utils";
|
||||||
import { getContext, setAnsiColors, encodeHtml } from 'utils'
|
import Debug from "debug";
|
||||||
import Debug from 'debug'
|
|
||||||
|
|
||||||
const debug = Debug('nuxt:render')
|
const debug = Debug('nuxt:render')
|
||||||
debug.color = 4 // Force blue color
|
debug.color = 4 // Force blue color
|
||||||
|
@ -46,6 +45,7 @@ export default class Renderer extends Tapable {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
|
/* istanbul ignore if */
|
||||||
if (nuxt.initialized) {
|
if (nuxt.initialized) {
|
||||||
// If nuxt already initialized
|
// If nuxt already initialized
|
||||||
this._ready = this.ready().catch(this.nuxt.errorHandler)
|
this._ready = this.ready().catch(this.nuxt.errorHandler)
|
||||||
|
@ -59,6 +59,7 @@ export default class Renderer extends Tapable {
|
||||||
}
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
|
/* istanbul ignore if */
|
||||||
if (this._ready) {
|
if (this._ready) {
|
||||||
return this._ready
|
return this._ready
|
||||||
}
|
}
|
||||||
|
@ -122,6 +123,7 @@ export default class Renderer extends Tapable {
|
||||||
}
|
}
|
||||||
this.resources[rawKey] = rawData
|
this.resources[rawKey] = rawData
|
||||||
data = transform(rawData)
|
data = transform(rawData)
|
||||||
|
/* istanbul ignore if */
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return // Invalid data ?
|
return // Invalid data ?
|
||||||
}
|
}
|
||||||
|
@ -337,10 +339,9 @@ export default class Renderer extends Tapable {
|
||||||
const { window } = await jsdom.JSDOM.fromURL(url, options)
|
const { window } = await jsdom.JSDOM.fromURL(url, options)
|
||||||
// If Nuxt could not be loaded (error from the server-side)
|
// If Nuxt could not be loaded (error from the server-side)
|
||||||
const nuxtExists = window.document.body.innerHTML.includes('window.__NUXT__')
|
const nuxtExists = window.document.body.innerHTML.includes('window.__NUXT__')
|
||||||
|
/* istanbul ignore if */
|
||||||
if (!nuxtExists) {
|
if (!nuxtExists) {
|
||||||
/* istanbul ignore next */
|
|
||||||
let error = new Error('Could not load the nuxt app')
|
let error = new Error('Could not load the nuxt app')
|
||||||
/* istanbul ignore next */
|
|
||||||
error.body = window.document.body.innerHTML
|
error.body = window.document.body.innerHTML
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ class Server {
|
||||||
this.options = nuxt.options
|
this.options = nuxt.options
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
|
/* istanbul ignore if */
|
||||||
if (nuxt.initialized) {
|
if (nuxt.initialized) {
|
||||||
// If nuxt already initialized
|
// If nuxt already initialized
|
||||||
this._ready = this.ready().catch(this.nuxt.errorHandler)
|
this._ready = this.ready().catch(this.nuxt.errorHandler)
|
||||||
|
@ -22,6 +23,7 @@ class Server {
|
||||||
}
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
|
/* istanbul ignore if */
|
||||||
if (this._ready) {
|
if (this._ready) {
|
||||||
return this._ready
|
return this._ready
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue