Skip to content

Commit

Permalink
fix issue where direct paths in the stories array would not resolve c…
Browse files Browse the repository at this point in the history
…orrectly

fixes: #15746
  • Loading branch information
Lasse Kuechler committed Aug 6, 2021
1 parent c3c131d commit e54a662
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions lib/core-common/src/utils/__tests__/to-require-context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,23 @@ const testCases = [
'../src/stories/components/Icon/Icon.mdx',
],
},
{
glob: '../src/stories/components/Icon.stories.js',
recursive: false,
validPaths: ['../src/stories/components/Icon.stories.js'],
invalidPaths: [
'../src/Icon.stories.mdx',
'../src/stories/components/Icon.stories/Icon.stories.mdx',
'../src/stories/components/Icon/Icon.mdx',
'../src/stories/components/Icon/Icon.stories.js',
'../src/stories/components/Icon/Icon.stories.ts',
'../src/stories/Icon.stories.js',
'../src/stories/Icon.stories.mdx',
'./Icon.stories.js',
'./src/stories/Icon.stories.js',
'./stories.js',
],
},
// DUMB GLOB
{
glob: '../src/stories/**/*.stories.[tj]sx',
Expand Down
2 changes: 1 addition & 1 deletion lib/core-common/src/utils/to-require-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const toRequireContext = (input: any) => {
const base = globResult.isGlob
? globResult.prefix + globResult.base
: path.dirname(fixedInput);
const globFallback = base !== '.' ? fixedInput.substr(base.length) : fixedInput;
const globFallback = base !== '.' ? fixedInput.substr(base.length + 1) : fixedInput;
const glob = globResult.isGlob ? globResult.glob : globFallback;

const regex = makeRe(glob, {
Expand Down

0 comments on commit e54a662

Please sign in to comment.