-
-
Notifications
You must be signed in to change notification settings - Fork 243
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: #775 node_modules not ignored. #802
Conversation
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.
Thanks for fixing that! Please add unit tests and extract the code so it's easier to understand the logic :)
const relativePart = relative(excludedPath, path); | ||
return relativePart && !relativePart.startsWith('..') && !isAbsolute(relativePart); |
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.
Please extract this code to a separate function and file.
// src/utils/path/is-inside-another-path.ts
import { relative, isAbsolute } from 'path';
function isInsideAnotherPath(path: string, anotherPath: string): boolean {
const relativePath = relative(anotherPath, path);
return relativePath && !relativePath.startsWith('..') && !isAbsolute(relativePath);
}
export { isInsideAnotherPath };
and write some unit tests for this function :)
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'll see what I can do. I don't have much spare time at the moment, so I don't know when I'll be able to make the necessary adjustments.
'aight! I fixed it up a little. |
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.
Thanks for the changes, looks good 👍
Looks like it doesn't work on linux and macos :) |
Can't even trust StackOverFlow? What's the world coming to... I'll take a look! |
Yeah, AFAIK, |
I modified the tests to use the platform-specific implementation. I reasoned that if you are matching against win32-paths when on Unix, something else entirely has gone majorly wrong. |
🎉 This PR is included in version 8.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Thanks for merging! Tested the changes today. At first it didn't work, but then I found out why. On a positive note, globs never worked, so it's not worse than before. Thoughts? |
The logic has been taken form this post.
On windows the "node_modules"-entry in the excluded array is absolute and looks something like this: "c:\\users\\..". The path that is tested is in unix-format. The string-test
startsWith
fails to account for this.I grabbed the code from StackOverflow, tested it directly by editing the compiled version of this plugin, modified it and added it here. It's late and I'm tired, so take a few extra looks at the logic. Our app would hang for about 30s, seemingly doing nothing after webpack was done compiling. It now starts instantly.