Nuxt/distributions/nuxt-ts/bin/nuxt-ts.js
Kevin Marrec 4f887f6963 fix(nuxt-ts): error catch in nuxt-ts binary (#5086)
* fix: nuxt-ts binary error catch

* test: update cli snapshot
2019-02-25 21:09:26 +01:00

22 lines
682 B
JavaScript
Executable File

#!/usr/bin/env node
const { resolve } = require('path')
// Globally indicate we are running in ts mode
process.env.NUXT_TS = 'true'
const nuxtCommands = ['dev', 'build', 'generate', 'start']
const rootDir = (process.argv[2] && !nuxtCommands.includes(process.argv[2])) ? process.argv[2] : process.cwd()
const tsConfigPath = resolve(rootDir, 'tsconfig.json')
const suffix = require('../package.json').name.includes('-edge') ? '-edge' : ''
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)