Skip to content

Commit

Permalink
Properly check storybookBaseDir against repository root rather than c…
Browse files Browse the repository at this point in the history
…urrent working directory
  • Loading branch information
ghengeveld committed May 6, 2024
1 parent a82fa62 commit 70098f4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions node-src/lib/checkStorybookBaseDir.ts
Expand Up @@ -4,10 +4,12 @@ import { invalidStorybookBaseDir } from '../ui/messages/errors/invalidStorybookB
import { Context, Stats } from '../types';
import pLimit from 'p-limit';
import { exitCodes, setExitCode } from './setExitCode';
import { getRepositoryRoot } from '../git/git';

export async function checkStorybookBaseDir(ctx: Context, stats: Stats) {
const repositoryRoot = await getRepositoryRoot();
const { storybookBaseDir = '' } = ctx.options;
ctx.log.debug('Storybook base directory:', storybookBaseDir);
ctx.log.debug('Storybook base directory:', path.join(repositoryRoot, storybookBaseDir));

// Find all js(x)/ts(x) files in stats that are not in node_modules
const sourceModuleFiles = stats.modules.filter(
Expand All @@ -22,7 +24,7 @@ export async function checkStorybookBaseDir(ctx: Context, stats: Stats) {
await Promise.any(
sourceModuleFiles.map((file) => {
return limitConcurrency(() => {
const absolutePath = path.join(storybookBaseDir, file.name);
const absolutePath = path.join(repositoryRoot, storybookBaseDir, file.name);

Check warning on line 27 in node-src/lib/checkStorybookBaseDir.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

node-src/lib/checkStorybookBaseDir.ts#L27

Detected possible user input going into a `path.join` or `path.resolve` function.
return new Promise((resolve, reject) =>
fs.access(absolutePath, (err) => {
if (err) {
Expand Down

0 comments on commit 70098f4

Please sign in to comment.