fix: improve error message when config fails to load in build (#7810)

**What**

Throws the original error when failing to load medusa-config during build.

Before it only threw "Failed to load medusa-config". Now it does:
![CleanShot 2024-06-24 at 11  17 46@2x](https://github.com/medusajs/medusa/assets/7554214/11120038-bba8-4d94-a78a-e8556a4e7f75)
This commit is contained in:
Sebastian Rindom authored and GitHub committed 2024-06-28 08:10:27 +00:00
1 parent 789d545b9e
commit ef259b3386
1 file changed
+6 -3
+6 -3
View File
@@ -36,7 +36,8 @@ async function findFiles(dir: string): Promise<string[]> {
) )
return paths.flat() return paths.flat()
} catch (e) { } catch (e) {
console.log(`Failed to read directory ${dir}`) console.error(`Failed to read directory ${dir}`)
console.error(e)
throw e throw e
} }
} }
@@ -121,7 +122,8 @@ export default async function ({ directory }: BuildArgs) {
) )
if (error) { if (error) {
console.log(`Failed to load medusa-config.js`) console.error(`Failed to load medusa-config.js`)
console.error(error)
process.exit(1) process.exit(1)
} }
@@ -158,7 +160,8 @@ export default async function ({ directory }: BuildArgs) {
await buildProductionBuild(adminOptions) await buildProductionBuild(adminOptions)
} catch (error) { } catch (error) {
console.log("Failed to build admin") console.error("Failed to build admin")
console.error(error)
} }
} }