Sandboxes: Fix scripts when pre-existing NODE_OPTIONS
contains whitespaces
#22677
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What I did
Hi guys. I've noticed the quotation marks in
storybook
andbuild-storybook
npm scripts in a generated sandbox'spackage.json
(e.g.,sandbox/react-vite-default-ts/package.json
) are incompatible with situations when pre-existingNODE_OPTIONS
contains a string value with whitespaces (e.g.,'--require "/Users/sook/Library/Application Support/Code/User/workspaceStorage/c9671de157069c282309baa6cfbc061f/ms-vscode.js-debug/bootloader.js" '
notice there's a whitespace inApplication Support
).Currently, the generated
storybook
script uses double quotes to wrap the final value ofNODE_OPTIONS
which will conflict with pre-existing double quotes that were escaping whitespaces (if any).This can be prevented by simply switching the outermost double quotes to single quotes (i.e.,
NODE_OPTIONS="${nodeOptionsString}"
toNODE_OPTIONS='${nodeOptionsString}'
).And.. that's all I did.
How to test
mkdir -p "/tmp/my space" && touch "/tmp/my space/temp.js" && NODE_OPTIONS='--require "/tmp/my space/temp.js"' yarn start ; rm -r "/tmp/my space"
mkdir -p "/tmp/my space" && touch "/tmp/my space/temp.js" && yarn task --task dev --template react-vite/default-ts ; rm -r "/tmp/my space"
and choose the first optionRun the sandbox in development mode (dev)
command not found: space/temp.js --preserve-symlinks --preserve-symlinks-main
After applying the suggested fix, running above again will successfully boot up the dev server.
Checklist
yarn test
andyarn task --task e2e-tests --template=react-vite/default-ts --start-from=auto
MIGRATION.MD
Maintainers
make sure to add the
ci:merged
orci:daily
GH label to it.["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]