Skip to content

Commit

Permalink
fix(react-native): storybook relative paths (#22031)
Browse files Browse the repository at this point in the history
Co-authored-by: Emily Xiong <xiongemi@gmail.com>
  • Loading branch information
arekkubaczkowski and xiongemi committed Apr 1, 2024
1 parent ef81455 commit 120cde6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/react-native/src/executors/storybook/storybook.impl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join } from 'path';
import { join, relative, resolve, dirname } from 'path';
import { ExecutorContext, logger, readJsonFile } from '@nx/devkit';
import { fileExists } from '@nx/workspace/src/utilities/fileutils';
import * as chalk from 'chalk';
Expand Down Expand Up @@ -66,9 +66,15 @@ export function runCliStorybook(
workspaceRoot: string,
options: ReactNativeStorybookOptions
) {
const storiesFiles: string[] = options.searchDir.flatMap((dir) =>
globSync(join(dir, options.pattern))
);
const storiesFiles: string[] = options.searchDir.flatMap((dir) => {
const storyFilePaths: string[] = globSync(join(dir, options.pattern));

return storyFilePaths.map((storyFilePath) => {
const loaderPath: string = resolve(dirname(options.outputFile));
return relative(loaderPath, storyFilePath);
});
});

if (storiesFiles.length === 0) {
logger.warn(`${chalk.bold.yellow('warn')} No stories found.`);
}
Expand Down

0 comments on commit 120cde6

Please sign in to comment.