Skip to content

Commit

Permalink
Merge pull request spox#90 from webframp/windows/localappdata
Browse files Browse the repository at this point in the history
Use LOCALAPPDATA for cache when on Windows
  • Loading branch information
chrisroberts authored Jan 14, 2017
2 parents 6ba1e00 + 435014d commit 26daa37
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/batali/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,19 @@ def manifest
end
end

# @return [String] correct user home location for platform
def user_home
if RUBY_PLATFORM =~ /mswin|mingw|windows/
ENV.fetch('LOCALAPPDATA', Dir.home)
else
Dir.home
end
end

# @return [String] path to local cache
def cache_directory(*args)
memoize(['cache_directory', *args].join('_')) do
directory = config.fetch(:cache_directory, File.join(Dir.home, '.batali', 'cache'))
directory = config.fetch(:cache_directory, File.join(user_home, '.batali', 'cache'))
ui.debug "Cache directory to persist cookbooks: #{directory}"
unless(args.empty?)
directory = File.join(directory, *args.map(&:to_s))
Expand Down

0 comments on commit 26daa37

Please sign in to comment.