Add --no-metadata option

This commit is contained in:
Alfred Xing 2014-11-23 15:38:00 -08:00
parent 75c5c16297
commit 2a5cf11ee2
3 changed files with 10 additions and 3 deletions

View File

@ -59,6 +59,7 @@ module Jekyll
c.option 'quiet', '-q', '--quiet', 'Silence output.'
c.option 'verbose', '-V', '--verbose', 'Print verbose output.'
c.option 'full_rebuild', '-f', '--full-rebuild', 'Clean the site before rebuilding.'
c.option 'no_metadata', '--no-metadata', 'Disable incremental regeneration.'
end
end

View File

@ -46,6 +46,8 @@ module Jekyll
#
# Returns a boolean.
def regenerate?(path, add = true)
return true if site.config['no_metadata']
# Check for path in cache
if @cache.has_key? path
return @cache[path]
@ -73,7 +75,7 @@ module Jekyll
#
# Returns nothing.
def add_dependency(path, dependency)
return if @metadata[path].nil?
return if (@metadata[path].nil? || site.config['no_metadata'])
@metadata[path]["deps"] << dependency unless @metadata[path]["deps"].include? dependency
regenerate? dependency
@ -102,7 +104,11 @@ module Jekyll
#
# Returns the read metadata.
def read_metadata
@metadata = (File.file?(metadata_file) && !(site.config['full_rebuild'])) ? SafeYAML.load(File.read(metadata_file)) : {}
@metadata = if !(site.config['full_rebuild'] || site.config['no_metadata']) && File.file?(metadata_file)
SafeYAML.load(File.read(metadata_file))
else
{}
end
end
end
end

View File

@ -328,7 +328,7 @@ module Jekyll
(item.respond_to?(:data) && item.data['regenerate'])
)
}
metadata.write
metadata.write unless site.config['no_metadata']
end
# Construct a Hash of Posts indexed by the specified Post attribute.