-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Persist paths in stack trace which have cwd as infix #3244
Conversation
How about replacing if (/\(?.+:\d+:\d+\)?$/.test(line)) {
line = line.replace(cwd, '');
} with if (/\(?.+:\d+:\d+\)?$/.test(line) && line.indexOf(cwd) === 0) {
line = line.replace(cwd, '');
} |
@harrysarson |
Yeah, good point @outsideris. Replacing based on the presence of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, Thanks. Please see my question...
@@ -597,7 +597,7 @@ exports.stackTraceFilter = function () { | |||
|
|||
// Clean up cwd(absolute) | |||
if (/\(?.+:\d+:\d+\)?$/.test(line)) { | |||
line = line.replace(cwd, ''); | |||
line = line.replace('(' + cwd, '('); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by using escape-string-regexp
, @ScottFreeCode meant do this:
line = line.replace(require('escape-string-regexp')(cwd), '');
Does that not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that doesn't.
In this case, escape-string-regexp
change nothing on the path. (I didn't check it with escape-string-regexp
on Windows)
> var cwd = '/Users/outsideris/github/mocha/';
undefined
> require('escape-string-regexp')(cwd)
'/Users/outsideris/github/mocha/'
So, line = line.replace(require('escape-string-regexp')(cwd), '');
will change at foo (/www/Users/outsideris/github/mocha/foo/index.js:13:226)
to at foo (/wwwfoo/index.js:13:226)
.
It resolves nothing here and results same as before I change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
Requirements
Description of the Change
As #3093 , when paths in stack trace messages have a current working directory as infix, it should not be replaced. So, I added
(
in front ofcwd
to replace only in a case of the paths started withcwd
. I assumed(
is always be there.Alternate Designs
@ScottFreeCode suggested
'escape-string-regexp'
package. However, I don't understand how it fixes this issue.Why should this be in core?
It is related with display stack trace in mocah.
Benefits
This is an edge case, so the most of users don't experience the issue. Some users like in docker can see correct path in a stack trace.
Possible Drawbacks
If a case of
(
is in front of a path can exist, the paths in a stack trace are not replaced with a current working directory.Applicable issues
#3093