Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Fix path separator issue in check-addon-order #26362

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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