From 4f887f6963a224726111bf7c98014e1b7296fef3 Mon Sep 17 00:00:00 2001 From: Kevin Marrec Date: Mon, 25 Feb 2019 21:09:26 +0100 Subject: [PATCH] fix(nuxt-ts): error catch in nuxt-ts binary (#5086) * fix: nuxt-ts binary error catch * test: update cli snapshot --- distributions/nuxt-ts/bin/nuxt-ts.js | 10 ++++--- .../unit/__snapshots__/command.test.js.snap | 28 +++++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/distributions/nuxt-ts/bin/nuxt-ts.js b/distributions/nuxt-ts/bin/nuxt-ts.js index 8c736ed77d..59d6ce03c5 100755 --- a/distributions/nuxt-ts/bin/nuxt-ts.js +++ b/distributions/nuxt-ts/bin/nuxt-ts.js @@ -11,9 +11,11 @@ const tsConfigPath = resolve(rootDir, 'tsconfig.json') const suffix = require('../package.json').name.includes('-edge') ? '-edge' : '' -require('@nuxt/typescript' + suffix).setup(tsConfigPath).then(() => { - require('@nuxt/cli' + suffix).run() -}).catch((error) => { +const errorHandler = (error) => { require('consola').fatal(error) process.exit(2) -}) +} + +require('@nuxt/typescript' + suffix).setup(tsConfigPath).then(() => { + require('@nuxt/cli' + suffix).run().catch(errorHandler) +}).catch(errorHandler) diff --git a/packages/cli/test/unit/__snapshots__/command.test.js.snap b/packages/cli/test/unit/__snapshots__/command.test.js.snap index fc6f1cf37f..96b3942fea 100644 --- a/packages/cli/test/unit/__snapshots__/command.test.js.snap +++ b/packages/cli/test/unit/__snapshots__/command.test.js.snap @@ -1,36 +1,36 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`cli/command builds help text 1`] = ` -" Usage: nuxt this is how you do it +" Usage: nuxt this is how you do it [options] - a very long description that should wrap - to the next line because is not longer + a very long description that should wrap + to the next line because is not longer than the terminal width Options: --spa, -s Launch in SPA mode - --universal, -u Launch in Universal + --universal, -u Launch in Universal mode (default) - --config-file, -c Path to Nuxt.js + --config-file, -c Path to Nuxt.js config file (default: nuxt.config.js) - --modern, -m Build/Start app for - modern browsers, e.g. server, client and + --modern, -m Build/Start app for + modern browsers, e.g. server, client and false - --force-exit Whether Nuxt.js - should force exit after the command has + --force-exit Whether Nuxt.js + should force exit after the command has finished - --version, -v Display the Nuxt + --version, -v Display the Nuxt version --help, -h Display this message - --port, -p Port number on which + --port, -p Port number on which to start the application - --hostname, -H Hostname on which to + --hostname, -H Hostname on which to start the application --unix-socket, -n Path to a UNIX socket - --foo very long option that - is longer than the terminal width and + --foo very long option that + is longer than the terminal width and should wrap to the next line "