diff --git a/lib/detect.js b/lib/detect.js index cb01cee..1ac4712 100644 --- a/lib/detect.js +++ b/lib/detect.js @@ -19,9 +19,9 @@ export async function detectFramework(path = "") { /** @type {import("./meta").SupportedFramework[]} */ const foundFrameworks = [] - if (packageJson.dependencies["next"]) foundFrameworks.push("next") - if (packageJson.dependencies["express"]) foundFrameworks.push("express") - if (packageJson.devDependencies["@sveltejs/kit"]) + if (packageJson?.dependencies?.["next"]) foundFrameworks.push("next") + if (packageJson?.dependencies?.["express"]) foundFrameworks.push("express") + if (packageJson?.devDependencies?.["@sveltejs/kit"]) foundFrameworks.push("sveltekit") if (foundFrameworks.length === 1) return foundFrameworks[0] @@ -33,7 +33,8 @@ export async function detectFramework(path = "") { return "unknown" } return "unknown" - } catch { + } catch (error) { + console.error(error) return "unknown" } } @@ -43,9 +44,11 @@ export async function requireFramework(path = "") { if (framework === "unknown") { console.error( - y.red(`No framework detected. Currently supported frameworks are: ${y.bold( - Object.keys(frameworks).join(", ") - )}`) + y.red( + `No framework detected. Currently supported frameworks are: ${y.bold( + Object.keys(frameworks).join(", ") + )}` + ) ) process.exit(0) @@ -53,4 +56,3 @@ export async function requireFramework(path = "") { return framework } -