Skip to content

Commit

Permalink
Expanded rake isolate to cover components (home-assistant#5349)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p authored and balloob committed May 25, 2018
1 parent 0a23a4b commit 358af5b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ deploy_branch = "master"

## -- Misc Configs -- ##

public_dir = "public/" # compiled site directory
public_dir = "public/" # compiled site directory
source_dir = "source" # source file directory
blog_index_dir = 'source/blog' # directory for your blog's index page (if you put your index in source/blog/index.html, set this to 'source/blog')
deploy_dir = "_deploy" # deploy directory (for Github pages deployment)
stash_dir = "_stash" # directory to stash posts for speedy generation
components_dir = "_components" # directory for component files
posts_dir = "_posts" # directory for blog files
themes_dir = ".themes" # directory for blog files
new_post_ext = "markdown" # default new post file extension when using the new_post task
Expand Down Expand Up @@ -169,18 +170,26 @@ task :new_page, :filename do |t, args|
end

# usage rake isolate[my-post]
desc "Move all other posts than the one currently being worked on to a temporary stash location (stash) so regenerating the site happens much more quickly."
desc "Move all other components and posts than the one currently being worked on to a temporary stash location (stash) so regenerating the site happens much more quickly."
task :isolate, :filename do |t, args|
stash_dir = "#{source_dir}/#{stash_dir}"
s_posts_dir = "#{stash_dir}/#{posts_dir}"
s_components_dir = "#{stash_dir}/#{components_dir}"
FileUtils.mkdir(stash_dir) unless File.exist?(stash_dir)
FileUtils.mkdir(s_posts_dir) unless File.exist?(s_posts_dir)
FileUtils.mkdir(s_components_dir) unless File.exist?(s_components_dir)
Dir.glob("#{source_dir}/#{posts_dir}/*.*") do |post|
FileUtils.mv post, stash_dir unless post.include?(args.filename)
FileUtils.mv post, s_posts_dir unless post.include?(args.filename)
end
Dir.glob("#{source_dir}/#{components_dir}/*.*") do |component|
FileUtils.mv component, s_components_dir unless component.include?(args.filename)
end
end

desc "Move all stashed posts back into the posts directory, ready for site generation."
task :integrate do
FileUtils.mv Dir.glob("#{source_dir}/#{stash_dir}/*.*"), "#{source_dir}/#{posts_dir}/"
FileUtils.mv Dir.glob("#{source_dir}/#{stash_dir}/#{posts_dir}/*.*"), "#{source_dir}/#{posts_dir}/"
FileUtils.mv Dir.glob("#{source_dir}/#{stash_dir}/#{components_dir}/*.*"), "#{source_dir}/#{components_dir}/"
end

desc "Clean out caches: .pygments-cache, .gist-cache, .sass-cache"
Expand Down

0 comments on commit 358af5b

Please sign in to comment.