From 6752bcc39cf1924e7c1534852dd5d76e9b7ec7ec Mon Sep 17 00:00:00 2001 From: Kevin Marrec Date: Wed, 24 Feb 2021 00:29:24 +0100 Subject: [PATCH] chore(runtime): add instructions for nuxt >= 2.15 --- packages/typescript-runtime/bin/nuxt-ts.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/typescript-runtime/bin/nuxt-ts.js b/packages/typescript-runtime/bin/nuxt-ts.js index 5ce44575..3e72d25b 100755 --- a/packages/typescript-runtime/bin/nuxt-ts.js +++ b/packages/typescript-runtime/bin/nuxt-ts.js @@ -1,8 +1,26 @@ #!/usr/bin/env node -const cli = (() => { try { return require('@nuxt/cli') } catch (err) { return require('@nuxt/cli-edge') } })() +let cli, hooks, version -const { hooks } = require('..') +try { + cli = require('@nuxt/cli') + version = require('@nuxt/cli/package.json').version +} catch (err) { + cli = require('@nuxt/cli-edge') + version = require('@nuxt/cli-edge/package.json').version +} + +const { coerce, gte } = require('semver') + +if (gte(coerce(version), '2.15.0')) { + const chalk = require('chalk') + const consola = require('consola') + consola.warn(chalk`You're using Nuxt {green ${version}}, which includes built-in TypeScript {blue runtime} support`) + consola.warn(chalk`You can safely use {green nuxt} instead of {yellow nuxt-ts} and remove {blue @nuxt/typescript-runtime} package`) + hooks = {} +} else { + hooks = require('..').hooks +} cli.run(null, hooks) .catch((error) => {