-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
fix: Make sure glob and minimatch are case insenitive on win32 #44
base: master
Are you sure you want to change the base?
Conversation
Supplies `nocase` option to minimatch and glob when on win32. Additionally changes `test-excludes` extension check to be case insenitive. Adds tests to support this behavior.
@bcoe brought to my attention that win32 can have case sensitivity toggled on. See bcoe/c8#192 (comment). I need to consider this. |
@j03m I did a tiny bit of research, I like the idea that this would just be a flag we set in c8 and nyc -- I couldn't find an easy way to detect this. |
Using this option would make the nyc configuration system specific. Couldn't we detect this with the following: 'use strict';
let memoized;
function isCaseInsensitive() {
if (typeof memoized !== 'undefined') {
return memoized;
}
let checkFile = __filename.toUpperCase();
/* istanbul ignore next: paranoid check */
if (checkFile === __filename) {
checkFile = __filename.toLowerCase();
}
try {
const stats = fs.statSync(checkFile)
memoized = stats.isFile();
} catch (error) {
memoized = false;
}
return memoized;
}
module.exports = isCaseInsensitive; In theory if this were in a |
I think what @coreyfarrell suggests is clever and could work. I will test and I'm happy to adjust the PR in this way (and the c8 PR). However, let me take us on a tangent for a moment. For clarity, I discovered this issue when using What do you think? Would we see this in the wild? Is this worth doing? CC: @bcoe |
I have seen istanbuljs/nyc#1265, not sure if this is related. Essentially under Windows someone was performing |
@j03m @coreyfarrell I'm open to the clever approach, with some mild concerns that we might find the problem is harder than we expect. I'd suggest that we immediately break it out as its own module in the Istanbul organization. @coreyfarrell cool if I create one and give @j03m write access, perhaps |
I'm fine with however you want to move forward. One thing I'd say is that I want the fs access checks to be restricted to win32 only. |
|
||
module.exports = { | ||
isOutsideDir(dir, filename) { | ||
return !minimatch(path.resolve(dir, filename), path.join(dir, '**'), minimatchOptions) |
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.
Fwiw, this still seems to the wrong result for me on Windows when dir
is relative ... I think if we want to resolve one path, we should also do so for the other?
return !minimatch(path.resolve(dir, filename), path.join(dir, '**'), minimatchOptions) | |
return !minimatch(path.resolve(dir, filename), path.resolve(dir, '**'), minimatchOptions) |
This still seems to be an issue in 2024 🙂 bcoe/c8#183 (comment) Would love to see some movement. Happy to try to update this PR / submit a new approach if there's changes that are needed. |
Supplies
nocase
option to minimatch and glob when on win32.Additionally changes
test-excludes
extension check to be caseinsenitive. Adds tests to support this behavior.