-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
CLI: Fix failure on dir with trailing slash #11000
Conversation
@@ -76,10 +76,11 @@ async function* expandPatternsInternal(context) { | |||
input: pattern, | |||
}); | |||
} else if (stat.isDirectory()) { | |||
const relativePath = path.relative(cwd, absolutePath) || "."; |
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.
If the goal of this line is only to remove trailing slashes, why not do .replace(/[/\\]+$/, '')
here to express the intent more clearly?
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.
I think the middle one foo//bar
was effected too.
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.
I'll confirm when I back to laptop, if it's true, I'll add comment.
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.
Tested, the tailing slash is the only problem, applied your suggestion.
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.
Your solution can't work, because \
can be the dirname, see this log https://github.com/prettier/prettier/runs/2746762536#step:6:1251
This commit da46196 works, but feel better/safer to use path.relative
, added comments b009878
Description
Fixes #9300
Fixes #10964
Checklist
docs/
directory).changelog_unreleased/*/XXXX.md
file followingchangelog_unreleased/TEMPLATE.md
.✨Try the playground for this PR✨