ISSUE-240: Method to convert path to pattern #392
Merged
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.
What is the purpose of this pull request?
Fix #240.
The main purpose is to allow users to stop processing Windows paths in each location where this package is used, using third-party packages.
The story about automatic pattern conversion is out of the issue now, as it is a separate big layer of problems.
What changes did you make? (Give an overview)
.escapePath
method now escapes a different set of special characters depending on the platform. Two methods have also been added:.escapePosixPath
,.escapeWindowsPath
.1.1. Added support for escaping an escape character (
\\
) when it is not followed by a special character.1.2. On Windows, the following characters
*?|[]
will no longer be escaped. Because it is not possible to use these characters in a path in DOS..convertPathToPattern
method, which allows you to safely convert DOS paths and UNC paths into patterns. Two methods have also been added:.convertPosixPathToPattern
,.convertWindowsPathToPattern
.2.1. This allows Windows paths to be passed as patterns after they have been converted. For example,
fg.convertPathToPattern('\\\\?\\c:\\Program Files (x86)') + '/**'
orfg.convertPathToPattern('C://Program Files (x86)') + '/**'
.2.2. Remove dependencies like
normalize-path
andslash
, which we previously suggested in the documentation.More details in the documentation:
escapePath
andconvertPathToPattern
.