Sandboxes: Fix scripts when pre-existing NODE_OPTIONS contains whitespaces#22677
Merged
Conversation
Contributor
|
what happens if the pre-existing Ie. if |
Contributor
Author
|
@JReinhold It seems like the recommended way to escape whitespaces is to use single quotes to wrap the outermost and escape whitespaces using double quotes inside, according to Node.js docs. P.S. Wow the hash tag of the link is very broken. I suggest searching ( |
NODE_OPTIONS contains whitespaces
JReinhold
approved these changes
Sep 12, 2023
38 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
storybookandbuild-storybooknpm scripts in a generated sandbox'spackage.json(e.g.,sandbox/react-vite-default-ts/package.json) are incompatible with situations when pre-existingNODE_OPTIONScontains 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
storybookscript uses double quotes to wrap the final value ofNODE_OPTIONSwhich 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-mainAfter applying the suggested fix, running above again will successfully boot up the dev server.
Checklist
yarn testandyarn task --task e2e-tests --template=react-vite/default-ts --start-from=autoMIGRATION.MD
Maintainers
make sure to add the
ci:mergedorci:dailyGH label to it.["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]