Skip to content

Commit

Permalink
Merge pull request #30471 from storybookjs/valentin/fix-local-sandbox…
Browse files Browse the repository at this point in the history
…-generation-in-link-mode-2

Build: Fix local sandbox generation in linked mode
  • Loading branch information
valentinpalkovic authored Feb 5, 2025
2 parents 30a5263 + b38ac98 commit 374ee3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions code/lib/cli-storybook/src/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ export const link = async ({ target, local, start }: LinkOptions) => {
reproDir = join(reprosDir, reproName);
}

const reproPackageJson = JSON.parse(
await readFile(join(reproDir, 'package.json'), { encoding: 'utf8' })
);

const version = spawnSync('yarn', ['--version'], {
cwd: reproDir,
stdio: 'pipe',
Expand All @@ -109,6 +105,10 @@ export const link = async ({ target, local, start }: LinkOptions) => {

logger.info(`Installing ${reproName}`);

const reproPackageJson = JSON.parse(
await readFile(join(reproDir, 'package.json'), { encoding: 'utf8' })
);

if (!reproPackageJson.devDependencies?.vite) {
reproPackageJson.devDependencies = {
...reproPackageJson.devDependencies,
Expand Down
6 changes: 5 additions & 1 deletion scripts/tasks/sandbox.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import path from 'node:path';

import dirSize from 'fast-folder-size';
// eslint-disable-next-line depend/ban-dependencies
import { pathExists, remove } from 'fs-extra';
Expand Down Expand Up @@ -49,7 +51,8 @@ export const sandbox: Task = {

options.link = false;
}
if (await this.ready(details, options)) {

if (!(await this.ready(details, options))) {
logger.info('🗑 Removing old sandbox dir');
await remove(details.sandboxDir);
}
Expand Down Expand Up @@ -151,6 +154,7 @@ export const sandbox: Task = {

const packageManager = JsPackageManagerFactory.getPackageManager({}, details.sandboxDir);

await remove(path.join(details.sandboxDir, 'node_modules'));
await packageManager.installDependencies();

logger.info(`✅ Storybook sandbox created at ${details.sandboxDir}`);
Expand Down

0 comments on commit 374ee3d

Please sign in to comment.