Skip to content

Commit bbf1e77

Browse files
valentinpalkovicstorybook-bot
authored andcommitted
Merge pull request #31937 from mrginglymus/fix-addon-detection-windows
Core: Improve addon detection in automigrations on windows (cherry picked from commit 70fff63)
1 parent 9c44db6 commit bbf1e77

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

code/core/src/common/utils/get-addon-names.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ describe('getAddonNames', () => {
4242
expect(result).toEqual(['@storybook/addon-highlight', '@storybook/addon-outline']);
4343
});
4444

45+
it('should extract addon names from windows absolute paths', () => {
46+
const config = {
47+
stories: [],
48+
addons: [
49+
'\\sandbox\\react-vite-default-ts\\node_modules\\@storybook\\addon-highlight',
50+
'\\sandbox\\react-vite-default-ts\\node_modules\\@storybook\\addon-outline',
51+
],
52+
};
53+
const result = getAddonNames(config);
54+
expect(result).toEqual(['@storybook/addon-highlight', '@storybook/addon-outline']);
55+
});
56+
4557
it('should extract addon names from pnpm paths', () => {
4658
const config = {
4759
stories: [],

code/core/src/common/utils/get-addon-names.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { StorybookConfig } from 'storybook/internal/types';
22

3+
import { normalizePath } from './normalize-path';
4+
35
export const getAddonNames = (mainConfig: StorybookConfig): string[] => {
46
const addons = mainConfig.addons || [];
57
const addonList = addons.map((addon) => {
@@ -14,6 +16,9 @@ export const getAddonNames = (mainConfig: StorybookConfig): string[] => {
1416
return undefined;
1517
}
1618

19+
// Ensure posix paths for plugin name sniffing
20+
name = normalizePath(name);
21+
1722
// For absolute paths, pnpm and yarn pnp,
1823
// Remove everything before and including "node_modules/"
1924
name = name.replace(/.*node_modules\//, '');

0 commit comments

Comments
 (0)