Skip to content

Conversation

@fisker
Copy link
Member

@fisker fisker commented Jun 1, 2021

Description

Fixes #9300
Fixes #10964

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@fisker fisker marked this pull request as ready for review June 1, 2021 01:57
input: pattern,
});
} else if (stat.isDirectory()) {
const relativePath = path.relative(cwd, absolutePath) || ".";
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member Author

@fisker fisker Jun 4, 2021

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

@fisker fisker merged commit ce96e48 into prettier:main Jun 11, 2021
@fisker fisker deleted the pattern-slash branch June 11, 2021 03:03
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI fails when passed a dir with trailing slash: prettier dir/ Cli different between prettier . and prettier ./

3 participants