Skip to content

Commit

Permalink
fix(cli): call path.replace only if it is a function (#10745)
Browse files Browse the repository at this point in the history
* fix(cli): call `path.replace` only if it is a function

* add changeset
  • Loading branch information
lilnasy authored Apr 11, 2024
1 parent f1bc3de commit d51951c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/late-spoons-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Fixes an issue where CLI commands could not report the reason for failure before exiting.
2 changes: 1 addition & 1 deletion packages/astro/src/core/errors/dev/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!) ?? [];
Expand Down

0 comments on commit d51951c

Please sign in to comment.