-
Notifications
You must be signed in to change notification settings - Fork 104
/
checkPresets.ts
32 lines (28 loc) · 1.04 KB
/
checkPresets.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { join, resolve } from 'path';
import { logger } from '@storybook/node-logger';
import { Preset, PluginOptions } from '../types';
const incompatiblePresets = [
'@storybook/preset-scss',
'@storybook/preset-typescript',
];
export const checkPresets = (options: PluginOptions): void => {
let presetsList: Preset[] = options.presetsList || ([] as Preset[]);
// Look for a legacy presets file if one exists.
if (!options.presetsList) {
try {
const configDir = resolve(options.configDir);
// eslint-disable-next-line global-require, import/no-dynamic-require, @typescript-eslint/no-var-requires
presetsList = require<Preset[]>(join(configDir, 'presets.js'));
} catch (e) {
// NOOP
}
}
presetsList.forEach((preset: string | { name: string }) => {
const presetName = typeof preset === 'string' ? preset : preset.name;
if (incompatiblePresets.includes(presetName)) {
logger.warn(
`\`${presetName}\` may not be compatible with \`@storybook/preset-create-react-app\``,
);
}
});
};