Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function generateTsConfigIfMissing(rootDir) {
const tsConfigPath = resolve(rootDir, 'tsconfig.json')
if (!existsSync(tsConfigPath)) {
const { confirmGeneration } = await prompt({
type: 'confirm',
name: 'confirmGeneration',
message: `Missing ${chalk.bold.blue('tsconfig.json')} in ${rootDir === process.cwd() ? 'current directory' : chalk.bold.green(resolve(rootDir))}, generate it ?`,
initial: true,
skip: env.minimal
})
if (confirmGeneration) {
const configToExtend = '@nuxt/typescript'
await writeJSON(tsConfigPath, {
extends: configToExtend,
compilerOptions: {
baseUrl: '.',
types: [
'@types/node',
'@nuxt/vue-app'
]
}
}, { spaces: 2 })
consola.info(`Extending ${chalk.bold.blue(`node_modules/${configToExtend}/tsconfig.json`)}`)
consola.success(`Generated successfully at ${chalk.bold.green(resolve(rootDir, 'tsconfig.json'))}`)