Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
Prev Previous commit
Next Next commit
add protection fallbacks back
  • Loading branch information
pi0 committed Sep 1, 2022
commit 92b488478bb1ccb63c1275692f2eca99fb8330b6
15 changes: 7 additions & 8 deletions packages/nuxi/src/utils/banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ export function showBanner (_clear?: boolean) {

export function showVersions (cwd: string) {
const _require = createRequire(cwd)
const getPkgWithVersion = (pkg: string, name: string) => {
const getPkgVersion = (pkg: string) => {
try {
const { version } = _require(`${pkg}/package.json`)
if (version) {
return name + ' ' + version
}
return version || ''
} catch { /* not found */ }
return pkg
return ''
}
const nuxtVersion = getPkgVersion('nuxt') || getPkgVersion('nuxt-edge')
const nitroVersion = getPkgVersion('nitropack')
console.log(
green(getPkgWithVersion('nuxt', 'Nuxt')),
gray('running with'),
gray(getPkgWithVersion('nitropack', 'Nitro'))
green(`Nuxt ${nuxtVersion}`),
nitroVersion ? gray(`running with Nitro ${nitroVersion}`) : ''
)
}