From a6f928b44eeb3eafc9bdda0b158d154e74e91a1b Mon Sep 17 00:00:00 2001 From: lilnasy <69170106+lilnasy@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:53:58 +0000 Subject: [PATCH 1/2] fix(cli): call `path.replace` only if it is a function --- packages/astro/src/core/errors/dev/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/core/errors/dev/utils.ts b/packages/astro/src/core/errors/dev/utils.ts index a61d1ee47c5a..f5de83de4758 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!) ?? []; From 7b97980d7977e4ec1e7265dc69702019e6b1e03c Mon Sep 17 00:00:00 2001 From: lilnasy <69170106+lilnasy@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:54:52 +0000 Subject: [PATCH 2/2] add changeset --- .changeset/late-spoons-knock.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/late-spoons-knock.md diff --git a/.changeset/late-spoons-knock.md b/.changeset/late-spoons-knock.md new file mode 100644 index 000000000000..0cca6ce612f7 --- /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.