Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix generate-helpers failing in URL-encoded path #13404

Merged
merged 1 commit into from May 31, 2021

Conversation

lightmare
Copy link
Contributor

@lightmare lightmare commented May 31, 2021

Q                       A
Fixed Issues? ø
Patch: Bug Fix? yes
Major: Breaking Change? no
Minor: New Feature? no
Tests Added + Pass? ø
Documentation PR Link n/a
Any Dependency Changes? ø
License MIT

make build fails if your working tree is inside a directory with some non-ASCII characters along the path (or spaces, or certain reserved characters, like % or #). Example output:

...
[19:50:34] Generating @babel/helpers runtime helpers
loading /home/foss%E2%9D%A4/nodejs/babel/packages/babel-helpers/src/helpers jsx.js
[19:50:34] 'generate-runtime-helpers' errored after 357 ms
[19:50:34] Error: ENOENT: no such file or directory, open '/home/foss%E2%9D%A4/nodejs/babel/packages/babel-helpers/src/helpers/jsx.js'
[19:50:34] 'build' errored after 360 ms
make: *** [Makefile:27: build-bundle] Error 1

This PR decodes the URL-encoded pathname before passing it to readFile.
I don't know how I would write a test for this, because the bug doesn't manifest unless you have the repository checked out under a path containing spaces, for example.

HELPERS_FOLDER.pathname may be URL-encoded, if the working tree's
absolute path contains spaces, some reserved characters, or anything
beyond ASCII.

readFile accepts a plain String or URL for the path, but does not
automatically decode URL-encoded Strings.
@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/46583/

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 4871fa4:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@nicolo-ribaudo nicolo-ribaudo merged commit b397aca into babel:main May 31, 2021
@existentialism existentialism added PR: Bug Fix 🐛 A type of pull request used for our changelog categories area: helpers labels Jun 1, 2021
@lightmare lightmare deleted the fix-build-path-url-encoded branch June 1, 2021 13:57
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 1, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: helpers outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants