Skip to content

Commit

Permalink
fix: improve storybook cli detection
Browse files Browse the repository at this point in the history
Automatically detect the presence of the `storybook` command when
considering possible launch strategies, even if `@storybook/cli` is not
installed. The `storybook` package provides the `storybook` binary for
Storybook 7 and above.
  • Loading branch information
joshbolduc committed Dec 15, 2024
1 parent 54f4042 commit 3583bb2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/server/taskCreators/storybookCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ const getStorybookCliLocation = async (configDir: Uri | undefined) => {
'storybook',
configDir,
async (uri) => {
try {
const version = await getInstalledPackageVersion('@storybook/cli', uri);
const cliPackages = ['storybook', '@storybook/cli'];

if (typeof version === 'string' && gte(version, VERSION_7_x_ALPHA)) {
return true;
for (const packageName of cliPackages) {
try {
const version = await getInstalledPackageVersion(packageName, uri);

if (typeof version === 'string' && gte(version, VERSION_7_x_ALPHA)) {
return true;
}
} catch {
// no-op; likely package.json couldn't be found or parsed
}
} catch {
// no-op; likely package.json couldn't be found or parsed
}

return false;
Expand Down

0 comments on commit 3583bb2

Please sign in to comment.