Check parent directories for Cakefiles#1687
Check parent directories for Cakefiles#1687jashkenas merged 2 commits intojashkenas:masterfrom fortes:1686_cakefile_parent_dirs
Conversation
|
+1 on the idea. Minor nitpick: The way the patch is implemented, there's always a redundant |
|
Refactored to avoid that extra call, let me know if there's anything else you need there. |
|
I dig it -- thanks for the patch. |
Check parent directories for Cakefiles
|
One quick question. It seems correct, in order to not have to worry about relative paths getting screwed up ... but is it correct for the process to Are there no use cases where you might want to run a cake task in the current subdirectory? |
|
@jashkenas: I think we should have an invariant that the working directory of a Cakefile is its containing directory. It wouldn't be very fun to author Cakefiles without that invariant. So, to more directly answer your question: I think it's fine. edit: after thinking about it more, I could go either way. It wouldn't be that big of a hassle to have to remember to reset your working directory at the top of a Cakefile if you're going to make assumptions about it. |
|
That's a fair point, @jashkenas -- Rakefiles tend to use We can recommend the equivalent code for Cakefiles: process.chdir path.dirname __filenameOr we can use @michaelficarra's suggestion and keep a static working directory -- but then we may need to expose the original path. |
|
FWIW, Rake exposes the directory from which the command is run as That may be the simplest model here for Cakefile authors. |
|
That should do the trick. |
Might be controversial, but figured I'd put it out there. Rake will crawl look for a Rakefile in parent directories, unless you specify the
-nosearchflag. Been a decade since I used Make, but I believe it does the same as well. Cake does not.I'm a CS novice, so apologies for any non-idiomatic code. Happy to make revisions.
Was issue #1686