question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

To not allow `[ '' ]` as `staticDirs` or `outputDir` argument in `buildStaticStandalone()` method

See original GitHub issue

When calling to copyAllStaticFiles() with [''] as argument (by mistake), it executes and ends up copying root folder and more collateral side effects happening.

https://github.com/storybookjs/storybook/blob/59ee9c3e4e4e9b2d2b80dafe503cbfac669df279/lib/core/src/server/build-static.ts#L104

Would be nice to throw, or not allow that value at TS level.

I would be happy to PR a fix if you agree on the problem

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
oscard0mcommented, Feb 21, 2021

@oscard0m The other PR broke it. I’ll should be able to put out a fix today. Thanks for the heads up! The command line should still work

no problem @shilman

I’m going to try it through command line. Thanks for the quick reply ❤️

~Apparently I’m not able to exactly try my changes due to this line~

~No matter if I pass it through package.json or cli arg, an empty string '' will be falsy in this line and will fallback to ./storybook-static~

~Checking this code, an idea coming to my mind: Should this fallback ./storybook/static added inside buildStatcStandalone() instead?~


Checked the code more deeply and apparently the line of code added in https://github.com/storybookjs/storybook/pull/13969 is just deffensive code for outputDir prop because any call to standalone buildStatics will be protected by:

https://github.com/storybookjs/storybook/blob/0327cae8b8330b4206158b765d87bbfe43f15b89/lib/core-server/src/build-static.ts#L105

It will always fallback to './storybook-static'

What needs an extra protection is staticDir which doesn’t have a fallback. Actions I would take are:

  • Revert this PR which is dead code or deffensive
    • Keeping unit tests to assure the fallback to './.storybook' could be interesting
  • To open I PR for adding a fallback to staticDir empty string. The original purpose of this issue

Let me know if you agree on it @shilman and how you would like to manage the revert + unit tests PR’s first

1reaction
shilmancommented, Feb 21, 2021

@oscard0m The other PR broke it. I’ll should be able to put out a fix today. Thanks for the heads up! The command line should still work

Read more comments on GitHub >

github_iconTop Results From Across the Web

msbuild -p:outputdir=c:\mydir being ignored - Stack Overflow
The MSDN doc for this tool says that I should be able to override the build directory using this parameter. What am I...
Read more >
storybookjs/storybook (Raised $170.00) - Issuehunt
To not allow `[ '' ]` as `staticDirs` or `outputDir` argument in `buildStaticStandalone()` method. Unfunded#13860created byoscard0m.
Read more >
CLI options - Storybook
configure/telemetry.md#how-to-opt-out) if you'd not like to share any information. Pass these commands the following options to alter Storybook's behavior.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found