Skip to content

Commit

Permalink
Merge pull request #26049 from storybookjs/norbert/fix-caret-in-upgrade
Browse files Browse the repository at this point in the history
CLI: Fix logic to add `^` packages in upgrade
  • Loading branch information
ndelangen authored Feb 22, 2024
2 parents dd10004 + b8adcad commit 22f7db6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions code/lib/cli/src/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,16 @@ export const doUpgrade = async ({
return dependency in versions;
}) as Array<keyof typeof versions>;
return monorepoDependencies.map((dependency) => {
let char = '^';
if (isOutdated) {
char = '';
}
if (isCanary) {
char = '';
}
/* add ^ modifier to the version if this is the latest stable or prerelease version
example outputs: @storybook/react@^8.0.0 */
const maybeCaret = (!isOutdated || isPrerelease) && !isCanary ? '^' : '';
return `${dependency}@${maybeCaret}${versions[dependency]}`;
return `${dependency}@${char}${versions[dependency]}`;
});
};

Expand Down

0 comments on commit 22f7db6

Please sign in to comment.