summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Arsh <69170106+lilnasy@users.noreply.github.com> 2024-04-11 14:56:46 +0530
committerGravatar GitHub <noreply@github.com> 2024-04-11 10:26:46 +0100
commitd51951ce6278d4b59deed938d65e1cb72b5102df (patch)
treebdd07afe496ce23acb084cad950de42a52235b51
parentf1bc3dea92e82290195800ddb9b27c61edbd3089 (diff)
downloadastro-d51951ce6278d4b59deed938d65e1cb72b5102df.tar.gz
astro-d51951ce6278d4b59deed938d65e1cb72b5102df.tar.zst
astro-d51951ce6278d4b59deed938d65e1cb72b5102df.zip
fix(cli): call path.replace only if it is a function (#10745)
* fix(cli): call `path.replace` only if it is a function * add changeset
-rw-r--r--.changeset/late-spoons-knock.md5
-rw-r--r--packages/astro/src/core/errors/dev/utils.ts2
2 files changed, 6 insertions, 1 deletions
diff --git a/.changeset/late-spoons-knock.md b/.changeset/late-spoons-knock.md
new file mode 100644
index 000000000..0cca6ce61
--- /dev/null
+++ b/.changeset/late-spoons-knock.md
@@ -0,0 +1,5 @@
+---
+"astro": patch
+---
+
+Fixes an issue where CLI commands could not report the reason for failure before exiting.
diff --git a/packages/astro/src/core/errors/dev/utils.ts b/packages/astro/src/core/errors/dev/utils.ts
index a61d1ee47..f5de83de4 100644
--- a/packages/astro/src/core/errors/dev/utils.ts
+++ b/packages/astro/src/core/errors/dev/utils.ts
@@ -174,7 +174,7 @@ function collectInfoFromStacktrace(error: SSRError & { stack: string }): StackIn
stackText.split('\n').find((ln) => ln.includes('src') || ln.includes('node_modules'));
// Disable eslint as we're not sure how to improve this regex yet
// eslint-disable-next-line regexp/no-super-linear-backtracking
- const source = possibleFilePath?.replace(/^[^(]+\(([^)]+).*$/, '$1').replace(/^\s+at\s+/, '');
+ const source = possibleFilePath?.replace?.(/^[^(]+\(([^)]+).*$/, '$1').replace(/^\s+at\s+/, '');
let file = source?.replace(/:\d+/g, '');
const location = /:(\d+):(\d+)/.exec(source!) ?? [];