Skip to content

Commit 695bd2e

Browse files
authored
fix(nuxthub): handle nuxthub version correctly (#3680)
1 parent 53b3dc8 commit 695bd2e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/presets/nuxthub.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,14 @@ export default definePreset({
4747
async setupNitro(nitroConfig, options) {
4848
const { nuxt } = options as unknown as { nuxt: Nuxt & { options: { hub: { db?: boolean | object, database?: boolean } } } }
4949
const hubConfig = nuxt.options.runtimeConfig.hub as unknown as { db: unknown & { applyMigrationsDuringBuild?: boolean }, dir: string }
50-
const nuxthubVersion = nuxt.options.hub?.database === true ? 0.9 : 0.10
5150
// NuxtHub <= 0.9
52-
if (nuxthubVersion <= 0.9) {
51+
if (nuxt.options.hub?.database === true) {
5352
if (nitroConfig.runtimeConfig?.content?.database?.type === 'sqlite') {
5453
logger.warn('Deploying with NuxtHub < 1 requires using D1 database, switching to D1 database with binding `DB`.')
5554
nitroConfig.runtimeConfig!.content!.database = { type: 'd1', bindingName: 'DB' }
5655
}
5756
}
58-
else if (nuxthubVersion >= 0.10) {
57+
else if (typeof nuxt.options.hub?.db === 'string' && typeof hubConfig.db === 'object') {
5958
const hubDb = hubConfig.db as unknown as { driver: string, connection: object }
6059
if (hubDb.driver === 'd1') {
6160
nitroConfig.runtimeConfig!.content!.database ||= { type: 'd1', bindingName: 'DB' }

0 commit comments

Comments
 (0)