Skip to content

Commit

Permalink
chore: update module
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Feb 18, 2024
1 parent 08d42e1 commit 62cf3f2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions modules/hub/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default defineNuxtModule({
name: 'hub'
},
async setup (options, nuxt) {
if (nuxt.options._prepare) return
const rootDir = nuxt.options.rootDir
const { resolve } = createResolver(import.meta.url)

Expand All @@ -31,7 +30,14 @@ export default defineNuxtModule({
projectSecretKey: process.env.NUXT_HUB_PROJECT_SECRET_KEY || '',
userToken: process.env.NUXT_HUB_USER_TOKEN || '',
})
if (/^\d+$/.test(String(hub.projectId))) {

// Preapre or Production mode, stop here
if (nuxt.options._prepare || !nuxt.options.dev) {
return
}

// Check if the project is linked to a NuxtHub project
if (hub.projectId && /^\d+$/.test(String(hub.projectId))) {
const project = await $fetch(`/api/projects/${hub.projectId}`, {
baseURL: hub.url,
headers: {
Expand All @@ -51,11 +57,6 @@ export default defineNuxtModule({
}
}

// Production mode
if (!nuxt.options.dev) {
return
}

if (hub.projectUrl) {
// TODO: check on hub.nuxt.com if the project is connected
logger.info(`Using remote hub from \`${hub.projectUrl}\``)
Expand Down

0 comments on commit 62cf3f2

Please sign in to comment.