Repository navigation
fix: use the real file path for a file dprint matched by its shebang - #70
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dprint is changing what file path it gives plugins for an extensionless file it matched by its shebang (dprint/dprint#1349): instead of the real path it gives the path with a marker and the mapped extension added (ex.
build.dprint-ext-added.shfor a file namedbuild). That makes a command'sextsmatch such a file, which fixes #69, but that path doesn't exist on disk.This makes the plugin use the path of the file on disk for everything other than matching by extension:
{{file_path}}is the real path (ex.build), so a command that reads the file from that path works.associationsare matched against the real path.A command's
extsare still matched against the path dprint provides.Since
{{file_path}}no longer tells a command the kind of file for these files, this also adds an{{ext}}variable: the extension without a leading period (ex.sh), or an empty string when there's none. It comes from the path dprint provides, so it's the extension the shebang maps to (ex.prettier --stdin-filepath file.{{ext}}).This only has an effect with a dprint version that includes the linked PR, which isn't merged yet, so the marker text (
.dprint-ext-added.) needs to stay in sync with it if it changes there.Closes #69