From 2d3c5b32f5c5f5b6c7f1399035cc9a8986f292f3 Mon Sep 17 00:00:00 2001 From: Nestor Vera Date: Wed, 23 Apr 2025 18:32:44 +0200 Subject: [PATCH] feat: add support for pnpm catalogs --- src/utils/nuxt.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/utils/nuxt.ts b/src/utils/nuxt.ts index 5270827..5ff50e0 100644 --- a/src/utils/nuxt.ts +++ b/src/utils/nuxt.ts @@ -111,7 +111,18 @@ export const getNuxtVersion = (): string | undefined => { }; if ('nuxt' in dependencies) { const nuxtVersion = dependencies.nuxt; - return nuxtVersion.replace('^', ''); + + if (!nuxtVersion.includes('catalog:')) { + return nuxtVersion.replace('^', ''); + } + + const workspaceConfigPath = `${projectRootDirectory()}/pnpm-workspace.yaml`; + const workspaceConfig = readFileSync(workspaceConfigPath, 'utf8') + + const regex = /[\s]['"]?nuxt['"]?[\s]*:[^0-9\n\r]*(?[0-9]+(?:\.[0-9]+){0,2})/g + const matches = regex.exec(workspaceConfig) + + return matches?.groups?.version } } else { return;