-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
remove dependency on path #23
Conversation
@@ -32,7 +36,7 @@ exports.isWindows = options => { | |||
if (options && typeof options.windows === 'boolean') { | |||
return options.windows; | |||
} | |||
return win32 === true || path.sep === '\\'; | |||
return win32 === true; |
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.
we don't need to check the path sep, since we already know if we're on windows from the above check.
And path.sep is only ever \ when on windows https://nodejs.org/api/path.html#path_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.
And path.sep is only ever \ when on windows
Naively, yes. But this also gave us a super easy way to explicitly set \\
as the path separator for tests.
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.
Sure, but as below, I don't think setting path.sep should be a supported use case, so using that logic isn't correct with that in mind
lib/picomatch.js
Outdated
return regex.test(path.basename(input)); | ||
|
||
// if it ends with a trailing / we filter out the last empty item that split will make | ||
const basename = input.split(/[\\/]/).filter(v => v !== '').pop(); |
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.
Move this regex out of the function to save mem.
The tests are broken now. They need to be fixed. Check for |
Ah right, just saw the comment here: picomatch/test/support/index.js Lines 5 to 7 in e7865c8
We could require path back in, making it a dynamic require but i'd like to avoid that if possible. |
Let's hear @jonschlinkert 's opinion. |
I’m fine with it.
…Sent from my iPhone
On Aug 21, 2019, at 6:50 PM, Paul Miller ***@***.***> wrote:
Let's hear @jonschlinkert 's opinion.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@Toxicable let’s remove tests then! |
test/options.js
Outdated
assert.deepEqual(match(['E:\\a\\b\\c.md'], 'E:/**/*.md'), ['E:/a/b/c.md']); | ||
assert.deepEqual(match(['E:\\a\\b\\c.md'], 'E:/**/*.md', { windows: false }), []); | ||
}); | ||
}); |
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.
why were these removed?
assert(isMatch('c:\\', '**', { windows: true })); | ||
assert(isMatch('C:\\Users\\', '**', { windows: true })); | ||
assert(isMatch('C:cwd/another', '**', { windows: true })); | ||
assert(isMatch('C:cwd\\another', '**', { windows: true })); | ||
}); |
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.
These are wrong. The entire point was to test these using platform detection, and without windows: true
path.sep = '/'; | ||
assert(isMatch('c:\\', '*{,/}', { windows: true })); | ||
assert(!isMatch('C:\\Users\\', '*', { windows: true })); | ||
assert(!isMatch('C:cwd\\another', '*', { windows: true })); | ||
}); |
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.
same here
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 don't follow, this test is simulating being on windows right?
Why not only run it on windows then?
assert(isMatch('\\\\unc\\admin$', '//*/*$', { windows: true })); | ||
assert(isMatch('\\\\unc\\admin$\\system32', '//*/*$/*32', { windows: true })); | ||
assert(isMatch('\\\\unc\\share\\foo', '//u*/s*/f*', { windows: true })); | ||
assert(isMatch('foo\\bar\\baz', 'f*/*/*', { windows: true })); | ||
}); |
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.
same here
@jonschlinkert For all the tests that are using windows specific inputs, with this new setup they should only be run on a windows host, right?. |
As I recall, I implemented the tests that way, and made the code comments in the tests, to remind myself that there was an edge case and reason they needed to be that way. Unfortunately, I don't remember at this point what the edge case was, and I'm not confident enough in my memory to say if I'm even correct. I'm not saying you're wrong, as you very well may be correct.
As my 10-year old nephew always says: "Never? Never ever ever?" It sounds like you're saying that I'm wrong and that there are no edge cases that your changes will effect, and that you 100% aware of all edge cases on all platforms. Is that correct? Are you positive that there are no scenarios in which a user on a non-windows platform would see windows paths, over a remote connection or otherwise? I'm not saying it happens, or that it happens often, I'm saying that it seems like there was a scenario where it happened, and I'm not 100% sure that it won't. |
Hey and just to be clear, I do appreciate the dialog and contribution. I'm just usually skeptical when an absolute assertion is made about Windows paths. |
Im not confidant that I know off the top of my head all use cases. We currently do a check to see if I propose that that since we already have a public API for supporting windows on a non windows OS, we don't need to do the So for our testing suite we can test windows works on linux with I'd also just like to point our that users should never modify |
@jonschlinkert So whats the plan here. |
Sorry for the really late reply. I think it's fine, but I just need to have a day where I can really dedicate some time to reviewing this comprehensively before I merge. Everything you said and did makes a lot of sense, I just need to digest it. |
@dawgwe1 you've been blocked |
Any progress in here? Our frontend builds is failing now because of |
If you want to use picomatch without any node.js dependencies, you can use this for now https://www.npmjs.com/package/picomatch-browser |
fixes micromatch/micromatch#175
This removes all dependency on the path module from nodejs.
This makes it easier for users downstream to bundle micromatch for use in browsers when using pre-configured bundlers like when using the Angular CLI or create react app