Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
avivkeller
left a comment
There was a problem hiding this comment.
I think copying the comments is important, the copy button is meant to copy the entire snippet contents
|
The reason for stripping When any macOS user clicks "Copy to clipboard" on zsh: command not found: #
zsh: no matches found: (add to your profile to persist):(Full clean-VM screenshots are in #9350.) If the copy button must strictly copy everything displayed inside the code block, an alternative way to solve this without hiding anything from the copy action would be to move explanatory text out of the code block (or split commands into separate copyable blocks without |
Users are not meant to copy the whole snippet and one shot it. The user is supposed to copy line by line and wait the output of each command, otherwise if they one shot they cannot troubleshoot issues. Moreover, in this sense the snippets are partially illustrative. |
ovflowd
left a comment
There was a problem hiding this comment.
This is over-engineering of removing comments, and the current behavior is intentional.
Description
Since macOS Catalina, the default interactive shell on macOS is
zsh, whereINTERACTIVE_COMMENTSis disabled by default. Clicking Copy to clipboard on any download snippet athttps://nodejs.org/en/downloadand pasting it intoTerminal.appemitszsh: command not found: #for every comment line and passes inline# Should print "..."comments as literal CLI arguments.This PR keeps the explanatory
#comments visible in the rendered code box for readability, while stripping shell#comments from the clipboard text when copying download snippets:copyText?: stringprop toBaseCodeBox(and forwards it throughCodeBox), preserving existingcontainerRef.current?.textContentbehavior for all other callers.stripShellComments()inapps/site/util/download/snippet.tsto remove full-line#comments and unquoted trailing inline#comments while preserving#inside single/double/backtick quotes and parameter expansions (e.g.${VAR#prefix}), and collapsing redundant blank lines.ReleaseCodeBoxto passcopyText={stripShellComments(parsedContent)}toCodeBox.stripShellCommentsandBaseCodeBox'scopyTextprop, plus a changeset for@node-core/ui-components.Validation
apps/site/util/__tests__/snippet.test.mjsandpackages/ui-components/src/Common/BaseCodeBox/__tests__/index.test.jsx.pnpm format,pnpm test,pnpm lint,pnpm lint:types, andpnpm build— all passed with zero errors.Related Issues
Refs #9350
Check List
pnpm formatto ensure the code follows the style guide.pnpm testto check if all tests are passing.pnpm buildto check if the website builds without errors.