diff --git a/lib/build.js b/lib/build.js index e6be5b33bc..277a2d9f9f 100644 --- a/lib/build.js +++ b/lib/build.js @@ -1,6 +1,5 @@ 'use strict' -const debug = require('debug')('nuxt:build') import _ from 'lodash' import co from 'co' import chokidar from 'chokidar' @@ -16,6 +15,7 @@ import clientWebpackConfig from './webpack/client.config.js' import serverWebpackConfig from './webpack/server.config.js' import chalk from 'chalk' import PostCompilePlugin from 'post-compile-webpack-plugin' +const debug = require('debug')('nuxt:build') const remove = pify(fs.remove) const readFile = pify(fs.readFile) const writeFile = pify(fs.writeFile) @@ -428,7 +428,7 @@ function webpackRunClient () { serverCompiler.run((err, stats) => { if (err) return reject(err) console.log('[nuxt:build:client]\n', stats.toString(webpackStats)) // eslint-disable-line no-console - if (stats.hasErrors()) return reject('Webpack build exited with errors') + if (stats.hasErrors()) return reject(new Error('Webpack build exited with errors')) resolve() }) }) @@ -441,7 +441,7 @@ function webpackRunServer () { serverCompiler.run((err, stats) => { if (err) return reject(err) console.log('[nuxt:build:server]\n', stats.toString(webpackStats)) // eslint-disable-line no-console - if (stats.hasErrors()) return reject('Webpack build exited with errors') + if (stats.hasErrors()) return reject(new Error('Webpack build exited with errors')) const bundlePath = join(serverConfig.output.path, serverConfig.output.filename) readFile(bundlePath, 'utf8') .then((bundle) => { diff --git a/lib/generate.js b/lib/generate.js index 99ee140463..0a42f4c4bc 100644 --- a/lib/generate.js +++ b/lib/generate.js @@ -1,6 +1,5 @@ 'use strict' -const debug = require('debug')('nuxt:generate') import fs from 'fs-extra' import co from 'co' import pify from 'pify' @@ -8,6 +7,7 @@ import _ from 'lodash' import { resolve, join, dirname, sep } from 'path' import { isUrl, promisifyRoute } from './utils' import { minify } from 'html-minifier' +const debug = require('debug')('nuxt:generate') const copy = pify(fs.copy) const remove = pify(fs.remove) const writeFile = pify(fs.writeFile) @@ -57,7 +57,6 @@ export default function () { console.error('Could not resolve routes') // eslint-disable-line no-console console.error(e) // eslint-disable-line no-console process.exit(1) - throw e }) }) .then((generateRoutes) => { diff --git a/lib/nuxt.js b/lib/nuxt.js index 660cbc48c5..611d6ab347 100644 --- a/lib/nuxt.js +++ b/lib/nuxt.js @@ -14,7 +14,6 @@ import { resolve, join } from 'path' import * as utils from './utils' class Nuxt { - constructor (options = {}) { var defaults = { dev: true, @@ -131,7 +130,6 @@ class Nuxt { if (typeof callback === 'function') callback() }) } - } export default Nuxt diff --git a/lib/render.js b/lib/render.js index e8e25e149e..3efe6f78e1 100644 --- a/lib/render.js +++ b/lib/render.js @@ -1,10 +1,10 @@ 'use strict' -const debug = require('debug')('nuxt:render') import ansiHTML from 'ansi-html' import co from 'co' import serialize from 'serialize-javascript' import { getContext, setAnsiColors, encodeHtml } from './utils' +const debug = require('debug')('nuxt:render') // force blue color debug.color = 4 setAnsiColors(ansiHTML) @@ -148,10 +148,10 @@ export function renderAndGetWindow (url, opts = {}) { window.scrollTo = function () {} // If Nuxt could not be loaded (error from the server-side) if (!window.__NUXT__) { - return reject({ + return reject(new Error({ message: 'Could not load the nuxt app', body: window.document.getElementsByTagName('body')[0].innerHTML - }) + })) } // Used by nuxt.js to say when the components are loaded and the app ready window.onNuxtReady(() => { diff --git a/lib/server.js b/lib/server.js index 1b9efae6d7..9f93754a21 100644 --- a/lib/server.js +++ b/lib/server.js @@ -3,7 +3,6 @@ const http = require('http') class Server { - constructor (nuxt) { this.nuxt = nuxt this.server = http.createServer(this.render.bind(this)) @@ -27,7 +26,6 @@ class Server { close (cb) { return this.server.close(cb) } - } export default Server diff --git a/package.json b/package.json index 874926452d..000add43d1 100644 --- a/package.json +++ b/package.json @@ -52,22 +52,22 @@ }, "dependencies": { "ansi-html": "^0.0.7", - "autoprefixer": "^6.7.2", - "babel-core": "^6.22.1", - "babel-loader": "^6.2.10", + "autoprefixer": "^6.7.7", + "babel-core": "^6.24.0", + "babel-loader": "^6.4.1", "babel-preset-vue-app": "^0.5.0", "chalk": "^1.1.3", "chokidar": "^1.6.1", "co": "^4.6.0", "compression": "^1.6.2", "css-loader": "^0.27.3", - "debug": "^2.6.1", + "debug": "^2.6.3", "extract-text-webpack-plugin": "2.1.0", - "file-loader": "^0.10.0", - "fs-extra": "^2.0.0", + "file-loader": "^0.10.1", + "fs-extra": "^2.1.2", "glob": "^7.1.1", "hash-sum": "^1.0.2", - "html-minifier": "^3.3.1", + "html-minifier": "^3.4.2", "html-webpack-plugin": "^2.28.0", "lodash": "^4.17.4", "lru-cache": "^4.0.2", @@ -78,41 +78,43 @@ "progress-bar-webpack-plugin": "^1.9.3", "script-ext-html-webpack-plugin": "^1.7.1", "serialize-javascript": "^1.3.0", - "serve-static": "^1.11.2", - "url-loader": "^0.5.7", - "vue": "^2.2.1", - "vue-loader": "^11.0.0", + "serve-static": "^1.12.1", + "url-loader": "^0.5.8", + "vue": "^2.2.4", + "vue-loader": "^11.1.4", "vue-meta": "^0.5.5", "vue-router": "^2.3.0", - "vue-server-renderer": "^2.2.0", + "vue-server-renderer": "^2.2.4", "vue-ssr-html-stream": "^2.2.0", - "vue-template-compiler": "^2.2.0", - "vuex": "^2.2.0", + "vue-template-compiler": "^2.2.4", + "vuex": "^2.2.1", "webpack": "^2.2.1", - "webpack-bundle-analyzer": "^2.3.0", - "webpack-dev-middleware": "^1.10.0", - "webpack-hot-middleware": "^2.17.0" + "webpack-bundle-analyzer": "^2.3.1", + "webpack-dev-middleware": "^1.10.1", + "webpack-hot-middleware": "^2.17.1" }, "devDependencies": { - "ava": "^0.18.1", + "ava": "^0.18.2", "babel-eslint": "^7.1.1", "babel-plugin-array-includes": "^2.0.3", "babel-plugin-transform-async-to-generator": "^6.22.0", - "babel-plugin-transform-runtime": "^6.22.0", + "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-es2015": "^6.22.0", "babel-preset-stage-2": "^6.22.0", "codecov": "^2.1.0", "copy-webpack-plugin": "^4.0.1", - "eslint": "^3.15.0", - "eslint-config-standard": "^7.1.0", - "eslint-plugin-html": "^2.0.0", - "eslint-plugin-promise": "^3.4.1", - "eslint-plugin-standard": "^2.0.1", + "eslint": "^3.18.0", + "eslint-config-standard": "^8.0.0-beta.2", + "eslint-plugin-html": "^2.0.1", + "eslint-plugin-import": "^2.2.0", + "eslint-plugin-node": "^4.2.1", + "eslint-plugin-promise": "^3.5.0", + "eslint-plugin-standard": "^2.1.1", "finalhandler": "^1.0.0", - "jsdom": "^9.10.0", + "jsdom": "^9.12.0", "json-loader": "^0.5.4", - "nyc": "^10.1.2", - "request": "^2.79.0", + "nyc": "^10.2.0-candidate.0", + "request": "^2.81.0", "request-promise-native": "^1.0.3", "webpack-node-externals": "^1.5.4" } diff --git a/test/basic.fail.generate.test.js b/test/basic.fail.generate.test.js index 9750e812f3..bdb3552f98 100644 --- a/test/basic.fail.generate.test.js +++ b/test/basic.fail.generate.test.js @@ -9,7 +9,7 @@ test('Fail with routes() which throw an error', t => { generate: { routes: function () { return new Promise((resolve, reject) => { - reject('Not today!') + reject(new Error('Not today!')) }) } } @@ -29,7 +29,7 @@ test('Fail with routes() which throw an error', t => { } nuxt.generate() .catch((e) => { - t.true(e === 'Not today!') + t.true(e.message === 'Not today!') }) }) }) diff --git a/test/utils.test.js b/test/utils.test.js index 3b80dc2c70..b466a54031 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -77,13 +77,13 @@ test('promisifyRoute (fn => promise)', t => { test('promisifyRoute (fn(cb) with error)', t => { const fn = function (cb) { - cb('Error here') + cb(new Error('Error here')) } const promise = utils.promisifyRoute(fn) t.is(typeof promise, 'object') return promise .catch((e) => { - t.is(e, 'Error here') + t.is(e.message, 'Error here') }) })