Skip to content

Commit

Permalink
Enforce --output-dir with --build-command
Browse files Browse the repository at this point in the history
  • Loading branch information
codykaup committed Oct 24, 2024
1 parent 6c57be1 commit a72c761
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 6 additions & 0 deletions node-src/lib/getOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,12 @@ export default function getOptions(ctx: InitialContext): Options {
throw new Error(incompatibleOptions(['--build-script-name', '--build-command']));
}

// --build-command can put the built Storybook anywhere. Rather than reading through the value,
// we require `--output-dir` to avoid the issue.
if (potentialOptions.buildCommand && !potentialOptions.outputDir) {
throw new Error(dependentOption('--build-command', '--output-dir'));
}

if (
typeof potentialOptions.junitReport === 'string' &&
path.extname(potentialOptions.junitReport) !== '.xml'
Expand Down
3 changes: 0 additions & 3 deletions node-src/tasks/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ export const setBuildCommand = async (ctx: Context) => {
const buildCommand = ctx.flags.buildCommand || ctx.options.buildCommand;

const buildCommandOptions = [
// NOTE: There is a bug in NX that outputs an invalid Storybook if the `--output-dir` flag is
// passed. Therefore, we need to skip that until it's fixed: https://github.com/nrwl/nx/issues/28594
// When that's fixed, we can remove the `!buildCommand &&` below.
!buildCommand && `--output-dir=${ctx.sourceDir}`,
ctx.git.changedFiles && webpackStatsSupported && `--webpack-stats-json=${ctx.sourceDir}`,
].filter((c): c is string => !!c);
Expand Down

0 comments on commit a72c761

Please sign in to comment.