Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions code/core/src/common/utils/get-addon-names.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ describe('getAddonNames', () => {
expect(result).toEqual(['@storybook/addon-highlight', '@storybook/addon-outline']);
});

it('should extract addon names from windows absolute paths', () => {
const config = {
stories: [],
addons: [
'\\sandbox\\react-vite-default-ts\\node_modules\\@storybook\\addon-highlight',
'\\sandbox\\react-vite-default-ts\\node_modules\\@storybook\\addon-outline',
],
};
const result = getAddonNames(config);
expect(result).toEqual(['@storybook/addon-highlight', '@storybook/addon-outline']);
});

it('should extract addon names from pnpm paths', () => {
const config = {
stories: [],
Expand Down
5 changes: 5 additions & 0 deletions code/core/src/common/utils/get-addon-names.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { StorybookConfig } from 'storybook/internal/types';

import { normalizePath } from './normalize-path';

export const getAddonNames = (mainConfig: StorybookConfig): string[] => {
const addons = mainConfig.addons || [];
const addonList = addons.map((addon) => {
Expand All @@ -14,6 +16,9 @@ export const getAddonNames = (mainConfig: StorybookConfig): string[] => {
return undefined;
}

// Ensure posix paths for plugin name sniffing
name = normalizePath(name);

// For absolute paths, pnpm and yarn pnp,
// Remove everything before and including "node_modules/"
name = name.replace(/.*node_modules\//, '');
Expand Down
Loading