Nuxt/distributions/nuxt-ts/bin/nuxt-ts.js
Kevin Marrec f18ce4e5d4 fix(ts): better tsconfig.json handling & improve tests (#4856)
* fix(ts): make ts-node register the right `tsconfig.json`

* setup guard & change require in nuxt-ts bin

* improve tests + test guard

* remove typescript-custom fixture

* Move TS unit test from `test/unit` to `packages/typescript/test`

* fix tests
2019-01-28 16:59:13 +03:30

20 lines
627 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' : ''
require('@nuxt/typescript' + suffix).setup(tsConfigPath).then(() => {
require('@nuxt/cli' + suffix).run()
}).catch((error) => {
require('consola').fatal(error)
process.exit(2)
})