Skip to content

Commit

Permalink
Core: Fix path separator issue in check-addon-order
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Mar 7, 2024
1 parent 55a3f07 commit 5ca2466
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions code/lib/core-common/src/utils/__tests__/check-addon-order.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const essentialAddons = [
'toolbars',
'measure',
'outline',
'highlight',
];

const pkgName = (entry: CoreCommon_AddonEntry): string => {
Expand All @@ -42,6 +43,22 @@ afterEach(() => {
describe.each([
['docs', 'controls', ['docs', 'controls']],
['docs', 'controls', ['docs', 'foo/node_modules/@storybook/addon-controls']],
[
'actions',
'interactions',
[
'foo\\node_modules\\@storybook\\addon-essentials',
'foo\\node_modules\\@storybook\\addon-interactions',
],
],
[
'actions',
'interactions',
[
'foo\\\\node_modules\\\\@storybook\\\\addon-essentials',
'foo\\\\node_modules\\\\@storybook\\\\addon-interactions',
],
],
['docs', 'controls', [{ name: '@storybook/addon-docs' }, 'controls']],
['docs', 'controls', ['essentials', 'controls']],
['docs', 'controls', ['essentials']],
Expand Down
2 changes: 1 addition & 1 deletion code/lib/core-common/src/utils/check-addon-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface Options {

const predicateFor = (addon: string) => (entry: CoreCommon_AddonEntry) => {
const name = (entry as CoreCommon_OptionsEntry).name || (entry as string);
return name && name.includes(addon);
return name && name.replaceAll(/(\\){1,2}/g, '/').includes(addon);
};

const isCorrectOrder = (
Expand Down

0 comments on commit 5ca2466

Please sign in to comment.