Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Support nanoc environments #859
Introduce support for nanoc environment and addresses #676.
Setting environments is done in nanoc.yaml using the
Selecting working environment can be done:
Good point regarding
This looks cool! A couple of things that I spotted so far:
changed the title from
[WIP] Support nanoc environments
[MVP] Support nanoc environments
Jun 7, 2016
Thanks @ddfreyne for this deep review. I fixed all but one:
Actually I did this to prevent having a mandatory argument when using environments. To my understanding if the user does not override the
What do you think?
I am fine with removing it :D I just prefer having a second thought before doing it.
One last think; should this PR include the documentation with it? How to do link new feature and the Nanoc.ws documentation?
p.s. sorry for all the parenthesis thingy; I relied on Rubocop.
Compiling with one env and pruning with another will cause the pruning to happen as if the site was compiled with the env used for pruning. I think that’s expected behavior.
The current implementation (which sets
Even retaining the current behavior for the default env is problematic, as output will be written to either
@ddfreyne I went over all fixes you mentioned. I did small fixup commits to ease the review process.
As much as I like the idea of adding environment support, this change makes certain assumptions that will cause problems with certain filters. For instance, the compass filter creates a .sass-cache folder in the project directory where nanoc compile is run. It's quite possible other filters may create temporary folders where files are cached.
As a result, the only safe way to use this feature is to only compile to one environment in a given project folder and not compile different environments in the same project folder.
Sure it's possible to configure the sass compiler to cache to a specific location but the setup is complicated because the environment setting needs to be passed to the compass config.rb and used to set the sass :cache_location property. Not only that, the configuration has to be made to config.rb so it's possible to run the compass command by itself outside of nanoc and have it pick up the right environment location.
Compass also supports environments so it would be ideal if the environment setting configured for Nanoc could be passed into the compass config.rb but that's a bit beyond the current topic.
However, aside from the filters nanoc supports out of the box, even if all of them were reviewed and fixed if necessary, there's no guarantee that third-party filters aren't writing or caching files to the project directory.
Even if switching environments to compile into the same folder is not supported, environment support is still very useful when building with one environment configuration such as development in its own folder, then push changes to a Git repository, e.g. github.com, then in a different folder configured as the production environment perform a git pull and recompile.