Skip to content

Commit

Permalink
feat: add warn about missing envs
Browse files Browse the repository at this point in the history
  • Loading branch information
Baroshem committed Jun 18, 2023
1 parent 99be07c commit 0a3a78e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export default defineNuxtModule<ModuleOptions>({
cloudName: process.env.CLOUDINARY_CLOUD_NAME || options.cloudName,
})

if (!nuxt.options.runtimeConfig.public.cloudinary?.cloudName) console.warn('`[@nuxtjs/cloudinary]` Environment variable `CLOUDINARY_CLOUD_NAME` or property `cloudinary.cloudName` missing')

installModule('@nuxt/image-edge')

const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url))
Expand Down
4 changes: 3 additions & 1 deletion src/runtime/composables/useCldImageUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import nuxtPkg from 'nuxt/package.json';
import pkg from '../../../package.json'

export const useCldImageUrl = (props: ConstructUrlProps) => {
if (!props.options.src) console.error("`@nuxtjs/cloudinary`: Property `src` is missing")
if (!props.options.src) console.error("`[@nuxtjs/cloudinary]`: Property `src` is missing")

const cldCloudName = props.config?.cloud?.cloudName || useRuntimeConfig().public.cloudinary.cloudName

if (!cldCloudName) console.warn('`[@nuxtjs/cloudinary]` Environment variable `CLOUDINARY_CLOUD_NAME` or property `cloudinary.cloudName` missing')

return {
url: constructCloudinaryUrl({
options: {
Expand Down

0 comments on commit 0a3a78e

Please sign in to comment.