-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Core: Add ./
to start of hidden file & folder paths
#16723
Conversation
Nx Cloud ReportCI ran the following commands for commit a580de0. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch
Sent with 💌 from NxCloud. |
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 like where this is going @IanVS. LMK if you need more help from me.
Seems to me the bug is here storybook/lib/core-common/src/utils/normalize-stories.ts Lines 51 to 53 in 5da733d
I don't know if there's a nice way to write it but we need something to essentially do: if (!(directoryFromWorking.startsWith(`.${path.sep}`) || directoryFromWorking.startsWith(`..${path.sep}`))) {
directoryFromWorking = `.${path.sep}${directoryFromWorking}`;
} |
Good catch, I think there are a few place spread around where this happens. There's also
|
21f636a
to
11f4f3e
Compare
./
to start of hidden file & folder paths
./
to start of hidden file & folder paths./
to start of hidden file & folder paths
@tmeasday I've created a helper function to add the I've also split the The tests that I wrote for the |
|
@IanVS we use the |
Thanks, but I think the problem is that the test is faking a windows path by using |
@IanVS unless those tests are new, in theory if it was passing before it means that the contract is that the code under test should be able to handle windows paths as input and did before this PR. our tests are a mess, so i'm not confident that theory matches practice in this case 🤷♂️ |
@shilman previously the code only looked for a |
Works for me! 👍 |
Using regex would cover all cases :) and you can consolidate the check into one regex |
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.
Really great stuff @IanVS. I would like to test it on a windows box (unless you did already?) -- let me do that before we merge it.
I've updated the check to use regex as discussed, and the windows-style path tests are now passing. I also added some windows-style path tests to my new function as well. What is still failing, is a test in Oh, and I don't have a windows box set up to run tests on, so if you do @tmeasday, and wouldn't mind running them, that would be much appreciated. I think there's also a way to set up github actions to run on a windows vm... I'll submit an experiment in a separate PR to see if that might be feasible. (Here it is, for whatever it's worth: #16744) |
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.
Unit tests are still failing?
toImportFn - webpackIncludeRegexp › matches only suitable paths - ../src/**/*.stories.tsx
- Expected - 1
+ Received + 5
- Array []
+ Array [
+ "/Users/user/code/.storybook/src/Icon.stories.tsx",
+ "/Users/user/code/.storybook/src/components/Icon.stories.tsx",
+ "/Users/user/code/.storybook/src/components/Icon.stories/Icon.stories.tsx",
+ ]
Yes, it's unclear to me if those are legitimate failures (if so it I believe it would be an existing issue prior to this PR), or if it is due to the way the test itself is constructed. I'm hoping @tmeasday has some insight. |
@IanVS I'm not sure exactly what's going on with these tests, but what's weird about this code is the So Kind of a confusing/weird test though. After your changes, the I would have thought it was the next test |
OK, retract that, the resolution is just relative to the |
Ahh, sorry I finally get it, sorry was a bit slow there. So yeah, the reason, is as I said:
So a matcher like Does that make sense @IanVS ? |
My understanding must be flawed, but I would have thought that if the config dir is |
I talked with Tom, he's going to comment out those tests and leave a note on why they are not really possible to test (due to webpack limitations) just in case anyone wonders about it in the future. |
./
to start of hidden file & folder paths./
to start of hidden file & folder paths
Issue:
I'm trying to troubleshoot storybookjs/builder-vite#155, where I'm having trouble with stories that are defined inside of my
.storybook
folder. I found that storybook only adds a./
to the start of a filename if it doesn't already find a single.
at the start of the file, which inadvertently picks up hidden files & folders.What I did
I've created a helper function to add the ./ when necessary, so it can be shared between the two places we know of where the same thing is done. I used @joshwooding's suggested snippet, because I couldn't think of anything better and I think it's pretty solid.
How to test
If your answer is yes to any of these, please make sure to include it in your PR.