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

Build: Handle special characters in path correctly #3583

Merged
merged 1 commit into from
Mar 14, 2016

Conversation

klimeryk
Copy link
Contributor

This PR fixes any outstanding and possible problems with special characters in the path to the directory where Calypso has been cloned into.
Basically, we enclose the path in single quotes - this way the shell won't treat the characters in it in any special way. Now the only character left that needs to be escaped is the single quote: '. Interestingly, the proper way to escape it seems to be '\''

Tested on:

  • Linux
  • OSX
  • Windows

Fixes #100 and #1345

Escape everything by enclosing the path in single quotes. Now the only
character left that needs to be escaped is single quote. Interestingly,
the proper way to escape it seems to be '\''
@klimeryk klimeryk added [Type] Bug [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. Build labels Feb 26, 2016
@klimeryk klimeryk self-assigned this Feb 26, 2016
THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd)
SINGLE_QUOTE := '
# We need to escape single quote as '\''
THIS_DIR := '$(subst $(SINGLE_QUOTE),$(SINGLE_QUOTE)\$(SINGLE_QUOTE)$(SINGLE_QUOTE),$(CURDIR))'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

CURDIR is a variable set by make pointing to the current working directory.
I don't see much sense in jumping through hoops to get the CWD, when we don't actually support invoking make from any other directory than the root of the project (where the Makefile resides).

Copy link
Contributor

Choose a reason for hiding this comment

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

There are many makefiles in the project that allows you to run local tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, but those Makefiles are independent of this one. So running make test directly from the directory with the tests obviously works as it should. As for make test from the root - that actually calls make -C /path/to/test - so, again, only the local Makefile will be used.
Just to confirm, I've tried both make test from the root directory to run all tests and make test in a subdirectory where some tests lie - both cases are working. But thanks for reminding me of this use case - it's good to double check stuff like that :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As a side note - all those individual Makefiles could be replaced in 99% of cases by a single, common Makefile 😁 One of those days, I'll find some time to create a PR for that.

Copy link
Contributor

Choose a reason for hiding this comment

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

As a side note - all those individual Makefiles could be replaced in 99% of cases by a single, common Makefile One of those days, I'll find some time to create a PR for that.

I would hope to get rid of all the Makefiles we use for testing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, one wonderful day we'll get #2108 resolved 😉

@folletto
Copy link
Contributor

Tested on OSX with a path like: ~/repo/wp-calypso {git}/.

HotReload doesn't work still. When a jsx file is edited, the console doesn't show up the "INVALID" message that highlights the correct watch triggering the reload process.

@folletto folletto added [Status] Needs Author Reply and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Feb 26, 2016
@klimeryk
Copy link
Contributor Author

Ah, damn hot reloading... I've investigated this and it seems like it's a bug somewhere higher up, not in Calypso. I've tried react-hot-boilerplate and it shows the same behavior. I wanted to report an issue there, but it seems like the project has been deprecated in favor of babel-plugin-react-transform. So I've tested react-transform-boilerplate - and the same behavior can be seen. So it might be something even higher up? But I have honestly no idea what/where it can be and how I can even debug this. I've looked at the emitted JS code and it looks like the path is correctly handled/escaped 😕
I wish this was a simple problem with the Makefile instead 😆

@folletto
Copy link
Contributor

I see, shame. :(

Thanks for having looked into this. :)

@klimeryk klimeryk added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] Needs Author Reply labels Feb 26, 2016
@blowery
Copy link
Contributor

blowery commented Mar 14, 2016

looks good, 🚢

@blowery blowery added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Mar 14, 2016
@blowery
Copy link
Contributor

blowery commented Mar 14, 2016

Since this is a few weeks old, you might want to rebase it first and verify it still passes tests on a current master.

klimeryk added a commit that referenced this pull request Mar 14, 2016
…s-in-path

Build: Handle special characters in path correctly
@klimeryk klimeryk merged commit 539f4e8 into master Mar 14, 2016
@klimeryk klimeryk deleted the fix/handle-special-characters-in-path branch March 14, 2016 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Framework: spaces and braces break the build / hot-reload
5 participants