From 558e05eb7391ed35ae6e670f1ed08d505a1ceecb Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Thu, 20 Feb 2020 23:17:32 +0530 Subject: [PATCH] Add an option to easily disable disk-cache (#7928) Merge pull request 7928 --- docs/_docs/configuration/options.md | 24 +++++++++++++++++++++++- features/cache.feature | 9 +++++++++ lib/jekyll/command.rb | 2 ++ lib/jekyll/site.rb | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/docs/_docs/configuration/options.md b/docs/_docs/configuration/options.md index 38bcbd87..8af5fa0c 100644 --- a/docs/_docs/configuration/options.md +++ b/docs/_docs/configuration/options.md @@ -43,13 +43,35 @@ class="flag">flags (specified on the command-line) that control them.

Safe

-

Disable custom plugins, and ignore symbolic links.

+

+ Disable custom plugins, caching to disk + and ignore symbolic links. +

safe: BOOL

--safe

+ + +

+ Disable Disk Cache + 4.1.0 +

+

+ Disable caching of content to disk in order to skip creating a + .jekyll-cache or similar directory at the source + to avoid interference with virtual environments and third-party + directory watchers. + Caching to disk is always disabled in safe mode. +

+ + +

disable_disk_cache: BOOL

+

--disable-disk-cache

+ +

Exclude

diff --git a/features/cache.feature b/features/cache.feature index f6f62af1..156b35ca 100644 --- a/features/cache.feature +++ b/features/cache.feature @@ -35,3 +35,12 @@ Feature: Cache But the .jekyll-cache directory should not exist And the _site directory should exist And I should see "

Hello World

" in "_site/index.html" + + Scenario: Disabling disk usage in non-safe mode + Given I have an "index.md" page that contains "{{ site.title }}" + And I have a configuration file with "title" set to "Hello World" + When I run jekyll build --disable-disk-cache + Then I should get a zero exit status + And the _site directory should exist + And I should see "

Hello World

" in "_site/index.html" + But the .jekyll-cache directory should not exist diff --git a/lib/jekyll/command.rb b/lib/jekyll/command.rb index 68bc8cbe..be8890e7 100644 --- a/lib/jekyll/command.rb +++ b/lib/jekyll/command.rb @@ -67,6 +67,8 @@ module Jekyll cmd.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder" cmd.option "unpublished", "--unpublished", "Render posts that were marked as unpublished" + cmd.option "disable_disk_cache", "--disable-disk-cache", + "Disable caching to disk in non-safe mode" cmd.option "quiet", "-q", "--quiet", "Silence output." cmd.option "verbose", "-V", "--verbose", "Print verbose output." cmd.option "incremental", "-I", "--incremental", "Enable incremental rebuild." diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 8aca2d65..281c2fe5 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -470,7 +470,7 @@ module Jekyll # Disable Marshaling cache to disk in Safe Mode def configure_cache Jekyll::Cache.cache_dir = in_source_dir(config["cache_dir"], "Jekyll/Cache") - Jekyll::Cache.disable_disk_cache! if safe + Jekyll::Cache.disable_disk_cache! if safe || config["disable_disk_cache"] end def configure_plugins