-
-
Notifications
You must be signed in to change notification settings - Fork 254
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
Proposal: major release to adopt forward slash, same as node-glob? #109
Conversation
0ab1d06
to
63eb5ad
Compare
Aargh, apologies, closed the wrong PR. Reopening. |
@@ -708,11 +698,6 @@ function match (f, partial) { | |||
|
|||
var options = this.options | |||
|
|||
// windows: need to use /, not \ | |||
if (path.sep !== '/') { |
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.
It's wrong. On Windows '/' character in pattern should match both '/' and '\' characters in file paths. There is not ideal slow implementation (i think this should be done in matching engine) but it 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.
I disagree. The idea here is to have a cross-platform API, with forward slash as path separator and backward slash as escape. That way you can still match literal forward (on Windows) and backward slashes by escaping them in the pattern.
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.
Pattern (as some kind of special language) SHOULD be cross-platform, and therefore need to use one special character (forward slash) as path separator on all platforms.
But, in opposite, file path is platform depended by definition .
For example, code:
if ( minimatch(filepath, 'foo/*.js') ) { /* do something*/
}
will perfectly works with current minimatch
version (or with my fork) on all platforms.
But with your commit the condition will do never trigger on Windows.
Moreover, imagine that one day will be invented a new operation system, and it developers decide to use pipe characted ('|') as path separator. The code example will work on this OS without any changes, because filepath foo|bar.js
will be internally replaced with foo/bar.js
(using code that you try to remove) and successfully match to the pattern foo/*.js
See also https://github.com/litmit/minimatch/tree/match-for-windows (works on Windows just enough for me). |
Has this proposal been superseded by micromatch/nanomatch@4d25ac8, or is it still being considered? Has there been any discussion about making this a configurable option, with three possible values:
FYI, I'm using Metalsmith, which uses minimatch heavily in the core library and its plugin ecosystem. On Windows systems, they do not normalize paths at all, instead relying on the Node core Path methods, which use platform-dependent separators. But of course, I want my code to also work when a colleague runs it on a Unix system, so my patterns all use |
@AmeliaBR there is should be one valid option :)
|
On reflection, I do agree that only But I'd still like the option of controlling what this matches to, depending on whether I'm doing path normalization before calling the library. |
@AmeliaBR The option that you suggested is needed, IMHO, in two rare cases:
|
Done on v5 |
As folks have pointed out before,
minimatch
misbehaves somewhat on Windows -- and it ends up sabotaging the documented usage ofnode-glob
, i.e. to "Please only use forward-slashes in glob expressions".In the spirit of constructive feedback, I figured I'd submit a PR. The first commit adds Appveyor CI configuration, and causes a bunch of failed tests.
The second removes the substitution of platform-specific path separator -- the assumption being that the caller follows the convention of only using forward-slashes.
Needless to say this would be a breaking change.
Related:
#92
#78
#64
#103
isaacs/node-glob#212