mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
feat(kit): add new isNuxtMajorVersion
compatibility util (#27579)
This commit is contained in:
parent
a4fc866d1c
commit
2475ee81cc
@ -81,19 +81,26 @@ export async function hasNuxtCompatibility (constraints: NuxtCompatibility, nuxt
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if current nuxt instance is version 2 legacy
|
* Check if current Nuxt instance is of specified major version
|
||||||
*/
|
*/
|
||||||
export function isNuxt2 (nuxt: Nuxt = useNuxt()) {
|
export function isNuxtMajorVersion (majorVersion: 2 | 3 | 4, nuxt: Nuxt = useNuxt()) {
|
||||||
const version = getNuxtVersion(nuxt)
|
const version = getNuxtVersion(nuxt)
|
||||||
return version[0] === '2' && version[1] === '.'
|
|
||||||
|
return version[0] === majorVersion.toString() && version[1] === '.'
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if current nuxt instance is version 3
|
* @deprecated Use `isNuxtMajorVersion(2, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
|
||||||
|
*/
|
||||||
|
export function isNuxt2 (nuxt: Nuxt = useNuxt()) {
|
||||||
|
return isNuxtMajorVersion(2, nuxt)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use `isNuxtMajorVersion(3, nuxt)` instead. This may be removed in \@nuxt/kit v5 or a future major version.
|
||||||
*/
|
*/
|
||||||
export function isNuxt3 (nuxt: Nuxt = useNuxt()) {
|
export function isNuxt3 (nuxt: Nuxt = useNuxt()) {
|
||||||
const version = getNuxtVersion(nuxt)
|
return isNuxtMajorVersion(3, nuxt)
|
||||||
return version[0] === '3' && version[1] === '.'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user